| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (!IsValid()) | 272 if (!IsValid()) |
| 273 return; | 273 return; |
| 274 | 274 |
| 275 base::ThreadRestrictions::AssertIOAllowed(); | 275 base::ThreadRestrictions::AssertIOAllowed(); |
| 276 file_.reset(); | 276 file_.reset(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 int64 File::Seek(Whence whence, int64 offset) { | 279 int64 File::Seek(Whence whence, int64 offset) { |
| 280 base::ThreadRestrictions::AssertIOAllowed(); | 280 base::ThreadRestrictions::AssertIOAllowed(); |
| 281 DCHECK(IsValid()); | 281 DCHECK(IsValid()); |
| 282 if (offset < 0) | |
| 283 return -1; | |
| 284 | 282 |
| 285 return lseek(file_.get(), static_cast<off_t>(offset), | 283 return lseek(file_.get(), static_cast<off_t>(offset), |
| 286 static_cast<int>(whence)); | 284 static_cast<int>(whence)); |
| 287 } | 285 } |
| 288 | 286 |
| 289 int File::Read(int64 offset, char* data, int size) { | 287 int File::Read(int64 offset, char* data, int size) { |
| 290 base::ThreadRestrictions::AssertIOAllowed(); | 288 base::ThreadRestrictions::AssertIOAllowed(); |
| 291 DCHECK(IsValid()); | 289 DCHECK(IsValid()); |
| 292 if (size < 0) | 290 if (size < 0) |
| 293 return -1; | 291 return -1; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 return FILE_ERROR_FAILED; | 476 return FILE_ERROR_FAILED; |
| 479 } | 477 } |
| 480 } | 478 } |
| 481 | 479 |
| 482 void File::SetPlatformFile(PlatformFile file) { | 480 void File::SetPlatformFile(PlatformFile file) { |
| 483 DCHECK(!file_.is_valid()); | 481 DCHECK(!file_.is_valid()); |
| 484 file_.reset(file); | 482 file_.reset(file); |
| 485 } | 483 } |
| 486 | 484 |
| 487 } // namespace base | 485 } // namespace base |
| OLD | NEW |