From b51f7bf9a501c5d2e62e3d33de109518b18fd0d2 Mon Sep 17 00:00:00 2001 From: "dumi@chromium.org" Date: Thu, 9 Sep 2010 22:09:30 +0000 Subject: Adding some utility functions that work on file handles, and adding the corresponding relays to file_util_proxy. BUG=none TEST=none Review URL: http://codereview.chromium.org/3303007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59007 0039d316-1c4b-4281-b951-d872f2087c98 --- base/file_util_proxy.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'base/file_util_proxy.h') 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 message_loop_proxy, + base::PlatformFile file, + GetFileInfoCallback* callback); + typedef Callback2& >::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::Type ReadWriteCallback; + static bool Read( + scoped_refptr 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 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 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 message_loop_proxy, + base::PlatformFile file, + long long length, + StatusCallback* callback); + + // Flushes a file. The callback can be NULL. + static bool Flush( + scoped_refptr message_loop_proxy, + base::PlatformFile file, + StatusCallback* callback); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); }; -- cgit v1.1