| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/files/file.h" | 5 #include "base/files/file.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 return HANDLE_EINTR(write(file_.get(), data, size)); | 314 return HANDLE_EINTR(write(file_.get(), data, size)); |
| 315 } | 315 } |
| 316 | 316 |
| 317 int64_t File::GetLength() { | 317 int64_t File::GetLength() { |
| 318 DCHECK(IsValid()); | 318 DCHECK(IsValid()); |
| 319 | 319 |
| 320 SCOPED_FILE_TRACE("GetLength"); | 320 SCOPED_FILE_TRACE("GetLength"); |
| 321 | 321 |
| 322 stat_wrapper_t file_info; | 322 stat_wrapper_t file_info; |
| 323 if (CallFstat(file_.get(), &file_info)) | 323 if (CallFstat(file_.get(), &file_info)) |
| 324 return false; | 324 return -1; |
| 325 | 325 |
| 326 return file_info.st_size; | 326 return file_info.st_size; |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool File::SetLength(int64_t length) { | 329 bool File::SetLength(int64_t length) { |
| 330 ThreadRestrictions::AssertIOAllowed(); | 330 ThreadRestrictions::AssertIOAllowed(); |
| 331 DCHECK(IsValid()); | 331 DCHECK(IsValid()); |
| 332 | 332 |
| 333 SCOPED_FILE_TRACE_WITH_SIZE("SetLength", length); | 333 SCOPED_FILE_TRACE_WITH_SIZE("SetLength", length); |
| 334 return !CallFtruncate(file_.get(), length); | 334 return !CallFtruncate(file_.get(), length); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 return !HANDLE_EINTR(fsync(file_.get())); | 525 return !HANDLE_EINTR(fsync(file_.get())); |
| 526 #endif | 526 #endif |
| 527 } | 527 } |
| 528 | 528 |
| 529 void File::SetPlatformFile(PlatformFile file) { | 529 void File::SetPlatformFile(PlatformFile file) { |
| 530 DCHECK(!file_.is_valid()); | 530 DCHECK(!file_.is_valid()); |
| 531 file_.reset(file); | 531 file_.reset(file); |
| 532 } | 532 } |
| 533 | 533 |
| 534 } // namespace base | 534 } // namespace base |
| OLD | NEW |