From 2897bccb0244e4c279fc638ecac59a600394dcb9 Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Wed, 7 Sep 2011 20:20:11 +0000 Subject: Disk cache: Use platform_file functions for POSIX. BUG=none TEST=none Review URL: http://codereview.chromium.org/7824027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99997 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/file_posix.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'net') diff --git a/net/disk_cache/file_posix.cc b/net/disk_cache/file_posix.cc index a80ae6c..b767c17 100644 --- a/net/disk_cache/file_posix.cc +++ b/net/disk_cache/file_posix.cc @@ -202,19 +202,24 @@ bool File::IsValid() const { bool File::Read(void* buffer, size_t buffer_len, size_t offset) { DCHECK(init_); - if (buffer_len > ULONG_MAX || offset > LONG_MAX) + if (buffer_len > static_cast(kint32max) || + offset > static_cast(kint32max)) return false; - int ret = pread(platform_file_, buffer, buffer_len, offset); + int ret = base::ReadPlatformFile(platform_file_, offset, + static_cast(buffer), buffer_len); return (static_cast(ret) == buffer_len); } bool File::Write(const void* buffer, size_t buffer_len, size_t offset) { DCHECK(init_); - if (buffer_len > ULONG_MAX || offset > ULONG_MAX) + if (buffer_len > static_cast(kint32max) || + offset > static_cast(kint32max)) return false; - int ret = pwrite(platform_file_, buffer, buffer_len, offset); + int ret = base::WritePlatformFile(platform_file_, offset, + static_cast(buffer), + buffer_len); return (static_cast(ret) == buffer_len); } @@ -256,7 +261,7 @@ bool File::SetLength(size_t length) { if (length > ULONG_MAX) return false; - return 0 == ftruncate(platform_file_, length); + return base::TruncatePlatformFile(platform_file_, length); } size_t File::GetLength() { @@ -277,7 +282,7 @@ void File::WaitForPendingIO(int* num_pending_io) { File::~File() { if (IsValid()) - close(platform_file_); + base::ClosePlatformFile(platform_file_); } bool File::AsyncWrite(const void* buffer, size_t buffer_len, size_t offset, -- cgit v1.1