| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // 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/eintr_wrapper.h" | 17 #include "base/eintr_wrapper.h" |
| 18 #include "base/file_path.h" |
| 18 #include "base/logging.h" | 19 #include "base/logging.h" |
| 19 #include "base/message_loop.h" | 20 #include "base/message_loop.h" |
| 20 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 21 #include "base/waitable_event.h" | 22 #include "base/waitable_event.h" |
| 22 #include "base/worker_pool.h" | 23 #include "base/worker_pool.h" |
| 23 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 24 | 25 |
| 25 // We cast back and forth, so make sure it's the size we're expecting. | 26 // We cast back and forth, so make sure it's the size we're expecting. |
| 26 COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit); | 27 COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit); |
| 27 | 28 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 int64 seek_position = Seek(FROM_BEGIN, bytes); | 438 int64 seek_position = Seek(FROM_BEGIN, bytes); |
| 438 if (seek_position != bytes) | 439 if (seek_position != bytes) |
| 439 return ERR_UNEXPECTED; | 440 return ERR_UNEXPECTED; |
| 440 | 441 |
| 441 // And truncate the file. | 442 // And truncate the file. |
| 442 int result = ftruncate(file_, bytes); | 443 int result = ftruncate(file_, bytes); |
| 443 return result == 0 ? seek_position : MapErrorCode(errno); | 444 return result == 0 ? seek_position : MapErrorCode(errno); |
| 444 } | 445 } |
| 445 | 446 |
| 446 } // namespace net | 447 } // namespace net |
| OLD | NEW |