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 |
284 #if defined(OS_ANDROID) | |
285 COMPILE_ASSERT(sizeof(int64) == sizeof(off64_t), off64_t_bit); | |
286 return lseek64(file_.get(), static_cast<off64_t>(offset), | |
287 static_cast<int>(whence)); | |
288 #else | |
289 COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit); | |
hashimoto
2014/06/19 01:51:56
nit: s/off_t_64_bit/off64_t_bit/?
rvargas (doing something else)
2014/06/19 17:11:43
Actually, the first message should be off64_t_64_b
| |
286 return lseek(file_.get(), static_cast<off_t>(offset), | 290 return lseek(file_.get(), static_cast<off_t>(offset), |
287 static_cast<int>(whence)); | 291 static_cast<int>(whence)); |
292 #endif | |
288 } | 293 } |
289 | 294 |
290 int File::Read(int64 offset, char* data, int size) { | 295 int File::Read(int64 offset, char* data, int size) { |
291 base::ThreadRestrictions::AssertIOAllowed(); | 296 base::ThreadRestrictions::AssertIOAllowed(); |
292 DCHECK(IsValid()); | 297 DCHECK(IsValid()); |
293 if (size < 0) | 298 if (size < 0) |
294 return -1; | 299 return -1; |
295 | 300 |
296 int bytes_read = 0; | 301 int bytes_read = 0; |
297 int rv; | 302 int rv; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 return FILE_ERROR_FAILED; | 484 return FILE_ERROR_FAILED; |
480 } | 485 } |
481 } | 486 } |
482 | 487 |
483 void File::SetPlatformFile(PlatformFile file) { | 488 void File::SetPlatformFile(PlatformFile file) { |
484 DCHECK(!file_.is_valid()); | 489 DCHECK(!file_.is_valid()); |
485 file_.reset(file); | 490 file_.reset(file); |
486 } | 491 } |
487 | 492 |
488 } // namespace base | 493 } // namespace base |
OLD | NEW |