Chromium Code Reviews| 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 <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 if (!IsValid()) | 273 if (!IsValid()) |
| 274 return; | 274 return; |
| 275 | 275 |
| 276 base::ThreadRestrictions::AssertIOAllowed(); | 276 base::ThreadRestrictions::AssertIOAllowed(); |
| 277 file_.reset(); | 277 file_.reset(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 int64 File::Seek(Whence whence, int64 offset) { | 280 int64 File::Seek(Whence whence, int64 offset) { |
| 281 base::ThreadRestrictions::AssertIOAllowed(); | 281 base::ThreadRestrictions::AssertIOAllowed(); |
| 282 DCHECK(IsValid()); | 282 DCHECK(IsValid()); |
| 283 if (offset < 0) | |
| 284 return -1; | |
| 285 | 283 |
| 286 return lseek(file_.get(), static_cast<off_t>(offset), | 284 return lseek(file_.get(), static_cast<off_t>(offset), |
|
wtc
2014/06/16 23:01:44
We should assert that sizeof(off_t) == 8. If sizeo
rvargas (doing something else)
2014/06/18 01:36:38
Done.
| |
| 287 static_cast<int>(whence)); | 285 static_cast<int>(whence)); |
| 288 } | 286 } |
| 289 | 287 |
| 290 int File::Read(int64 offset, char* data, int size) { | 288 int File::Read(int64 offset, char* data, int size) { |
| 291 base::ThreadRestrictions::AssertIOAllowed(); | 289 base::ThreadRestrictions::AssertIOAllowed(); |
| 292 DCHECK(IsValid()); | 290 DCHECK(IsValid()); |
| 293 if (size < 0) | 291 if (size < 0) |
| 294 return -1; | 292 return -1; |
| 295 | 293 |
| 296 int bytes_read = 0; | 294 int bytes_read = 0; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 return FILE_ERROR_FAILED; | 477 return FILE_ERROR_FAILED; |
| 480 } | 478 } |
| 481 } | 479 } |
| 482 | 480 |
| 483 void File::SetPlatformFile(PlatformFile file) { | 481 void File::SetPlatformFile(PlatformFile file) { |
| 484 DCHECK(!file_.is_valid()); | 482 DCHECK(!file_.is_valid()); |
| 485 file_.reset(file); | 483 file_.reset(file); |
| 486 } | 484 } |
| 487 | 485 |
| 488 } // namespace base | 486 } // namespace base |
| OLD | NEW |