| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include <errno.h> | 5 #include <errno.h> |
| 6 #include <fcntl.h> | 6 #include <fcntl.h> |
| 7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 #include <libgen.h> | 9 #include <libgen.h> |
| 10 #include <limits.h> | 10 #include <limits.h> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return write(handle_->fd(), buffer, num_bytes); | 66 return write(handle_->fd(), buffer, num_bytes); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 off_t File::Position() { | 70 off_t File::Position() { |
| 71 ASSERT(handle_->fd() >= 0); | 71 ASSERT(handle_->fd() >= 0); |
| 72 return lseek(handle_->fd(), 0, SEEK_CUR); | 72 return lseek(handle_->fd(), 0, SEEK_CUR); |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 off_t File::SetPosition(int64_t position) { | 76 bool File::SetPosition(int64_t position) { |
| 77 ASSERT(handle_->fd() >= 0); | 77 ASSERT(handle_->fd() >= 0); |
| 78 return lseek(handle_->fd(), position, SEEK_SET); | 78 return (lseek(handle_->fd(), position, SEEK_SET) != -1); |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 bool File::Truncate(int64_t length) { |
| 83 ASSERT(handle_->fd() >= 0); |
| 84 return (ftruncate(handle_->fd(), length) != -1); |
| 85 } |
| 86 |
| 87 |
| 82 void File::Flush() { | 88 void File::Flush() { |
| 83 ASSERT(handle_->fd() >= 0); | 89 ASSERT(handle_->fd() >= 0); |
| 84 fsync(handle_->fd()); | 90 fsync(handle_->fd()); |
| 85 } | 91 } |
| 86 | 92 |
| 87 | 93 |
| 88 off_t File::Length() { | 94 off_t File::Length() { |
| 89 ASSERT(handle_->fd() >= 0); | 95 ASSERT(handle_->fd() >= 0); |
| 90 off_t position = lseek(handle_->fd(), 0, SEEK_CUR); | 96 off_t position = lseek(handle_->fd(), 0, SEEK_CUR); |
| 91 if (position < 0) { | 97 if (position < 0) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 167 |
| 162 | 168 |
| 163 const char* File::PathSeparator() { | 169 const char* File::PathSeparator() { |
| 164 return "/"; | 170 return "/"; |
| 165 } | 171 } |
| 166 | 172 |
| 167 | 173 |
| 168 const char* File::StringEscapedPathSeparator() { | 174 const char* File::StringEscapedPathSeparator() { |
| 169 return "/"; | 175 return "/"; |
| 170 } | 176 } |
| OLD | NEW |