| 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/histogram.h" | |
| 21 #include "base/logging.h" | 20 #include "base/logging.h" |
| 22 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
| 23 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 24 #include "base/waitable_event.h" | 23 #include "base/waitable_event.h" |
| 25 #include "base/worker_pool.h" | 24 #include "base/worker_pool.h" |
| 26 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 27 | 26 |
| 28 // We cast back and forth, so make sure it's the size we're expecting. | 27 // 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); | 28 COMPILE_ASSERT(sizeof(int64) == sizeof(off_t), off_t_64_bit); |
| 30 | 29 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 int64 seek_position = Seek(FROM_BEGIN, bytes); | 473 int64 seek_position = Seek(FROM_BEGIN, bytes); |
| 475 if (seek_position != bytes) | 474 if (seek_position != bytes) |
| 476 return ERR_UNEXPECTED; | 475 return ERR_UNEXPECTED; |
| 477 | 476 |
| 478 // And truncate the file. | 477 // And truncate the file. |
| 479 int result = ftruncate(file_, bytes); | 478 int result = ftruncate(file_, bytes); |
| 480 return result == 0 ? seek_position : MapErrorCode(errno); | 479 return result == 0 ? seek_position : MapErrorCode(errno); |
| 481 } | 480 } |
| 482 | 481 |
| 483 } // namespace net | 482 } // namespace net |
| OLD | NEW |