diff options
author | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 03:01:14 +0000 |
---|---|---|
committer | dumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 03:01:14 +0000 |
commit | 3fb43ed1ad7bcfeb686aa48e296ffbc639b35ad7 (patch) | |
tree | 652cdff2f723df25189f248740a310dc10583460 /base/file_util_proxy.h | |
parent | 2758379366b4aafde0bce40b7d619840080b5387 (diff) | |
download | chromium_src-3fb43ed1ad7bcfeb686aa48e296ffbc639b35ad7.zip chromium_src-3fb43ed1ad7bcfeb686aa48e296ffbc639b35ad7.tar.gz chromium_src-3fb43ed1ad7bcfeb686aa48e296ffbc639b35ad7.tar.bz2 |
Adding some functions that operate on file handles.
TEST=platform_file_unittest.cc
BUG=none
TBR=darin
Review URL: http://codereview.chromium.org/3354020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_proxy.h')
-rw-r--r-- | base/file_util_proxy.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h index 929dcd7..581738d 100644 --- a/base/file_util_proxy.h +++ b/base/file_util_proxy.h @@ -72,6 +72,11 @@ class FileUtilProxy { const FilePath& file_path, GetFileInfoCallback* callback); + static bool GetFileInfoFromPlatformFile( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + base::PlatformFile file, + GetFileInfoCallback* callback); + typedef Callback2<base::PlatformFileError /* error code */, const std::vector<base::file_util_proxy::Entry>& >::Type ReadDirectoryCallback; @@ -119,6 +124,52 @@ class FileUtilProxy { const FilePath& file_path, StatusCallback* callback); + // Reads from a file. On success, the file pointer is moved to position + // |offset + bytes_to_read| in the file. The callback can be NULL. + typedef Callback2<base::PlatformFileError /* error code */, + int /* bytes read/written */>::Type ReadWriteCallback; + static bool Read( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + base::PlatformFile file, + int64 offset, + char* buffer, + int bytes_to_read, + ReadWriteCallback* callback); + + // Writes to a file. If |offset| is greater than the length of the file, + // |false| is returned. On success, the file pointer is moved to position + // |offset + bytes_to_write| in the file. If The callback can be NULL. + static bool Write( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + base::PlatformFile file, + int64 offset, + const char* buffer, + int bytes_to_write, + ReadWriteCallback* callback); + + // Touches a file. The callback can be NULL. + static bool Touch( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + base::PlatformFile file, + const base::Time& last_access_time, + const base::Time& last_modified_time, + StatusCallback* callback); + + // Truncates a file to the given length. If |length| is greater than the + // current length of the file, the file will be extended with zeroes. + // The callback can be NULL. + static bool Truncate( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + base::PlatformFile file, + long long length, + StatusCallback* callback); + + // Flushes a file. The callback can be NULL. + static bool Flush( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + base::PlatformFile file, + StatusCallback* callback); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); }; |