OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // For 64-bit file access (off_t = off64_t, lseek64, etc). | 5 // For 64-bit file access (off_t = off64_t, lseek64, etc). |
6 #define _FILE_OFFSET_BITS 64 | 6 #define _FILE_OFFSET_BITS 64 |
7 | 7 |
8 #include "net/base/file_stream.h" | 8 #include "net/base/file_stream.h" |
9 | 9 |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 #include <sys/stat.h> | 11 #include <sys/stat.h> |
12 #include <fcntl.h> | 12 #include <fcntl.h> |
13 #include <unistd.h> | 13 #include <unistd.h> |
14 #include <errno.h> | 14 #include <errno.h> |
15 | 15 |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/eintr_wrapper.h" | 18 #include "base/eintr_wrapper.h" |
19 #include "base/file_path.h" | 19 #include "base/file_path.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
23 #include "base/string_util.h" | 23 #include "base/string_util.h" |
24 #include "base/threading/worker_pool.h" | 24 #include "base/threading/worker_pool.h" |
25 #include "base/waitable_event.h" | 25 #include "base/synchronization/waitable_event.h" |
26 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
27 | 27 |
28 // We cast back and forth, so make sure it's the size we're expecting. | 28 // We cast back and forth, so make sure it's the size we're expecting. |
29 COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit); | 29 COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit); |
30 | 30 |
31 // Make sure our Whence mappings match the system headers. | 31 // Make sure our Whence mappings match the system headers. |
32 COMPILE_ASSERT(net::FROM_BEGIN == SEEK_SET && | 32 COMPILE_ASSERT(net::FROM_BEGIN == SEEK_SET && |
33 net::FROM_CURRENT == SEEK_CUR && | 33 net::FROM_CURRENT == SEEK_CUR && |
34 net::FROM_END == SEEK_END, whence_matches_system); | 34 net::FROM_END == SEEK_END, whence_matches_system); |
35 | 35 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 int64 seek_position = Seek(FROM_BEGIN, bytes); | 472 int64 seek_position = Seek(FROM_BEGIN, bytes); |
473 if (seek_position != bytes) | 473 if (seek_position != bytes) |
474 return ERR_UNEXPECTED; | 474 return ERR_UNEXPECTED; |
475 | 475 |
476 // And truncate the file. | 476 // And truncate the file. |
477 int result = ftruncate(file_, bytes); | 477 int result = ftruncate(file_, bytes); |
478 return result == 0 ? seek_position : MapErrorCode(errno); | 478 return result == 0 ? seek_position : MapErrorCode(errno); |
479 } | 479 } |
480 | 480 |
481 } // namespace net | 481 } // namespace net |
OLD | NEW |