| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "bin/file.h" | 5 #include "bin/file.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <io.h> | 8 #include <io.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 return (lseek(handle_->fd(), position, SEEK_SET) != -1); | 75 return (lseek(handle_->fd(), position, SEEK_SET) != -1); |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 bool File::Truncate(int64_t length) { | 79 bool File::Truncate(int64_t length) { |
| 80 ASSERT(handle_->fd() >= 0); | 80 ASSERT(handle_->fd() >= 0); |
| 81 return (chsize(handle_->fd(), length) != -1); | 81 return (chsize(handle_->fd(), length) != -1); |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 void File::Flush() { | 85 bool File::Flush() { |
| 86 ASSERT(handle_->fd()); | 86 ASSERT(handle_->fd()); |
| 87 _commit(handle_->fd()); | 87 return _commit(handle_->fd()) != -1; |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 off_t File::Length() { | 91 off_t File::Length() { |
| 92 ASSERT(handle_->fd() >= 0); | 92 ASSERT(handle_->fd() >= 0); |
| 93 off_t position = lseek(handle_->fd(), 0, SEEK_CUR); | 93 off_t position = lseek(handle_->fd(), 0, SEEK_CUR); |
| 94 if (position < 0) { | 94 if (position < 0) { |
| 95 // The file is not capable of seeking. Return an error. | 95 // The file is not capable of seeking. Return an error. |
| 96 return -1; | 96 return -1; |
| 97 } | 97 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 const char* File::StringEscapedPathSeparator() { | 212 const char* File::StringEscapedPathSeparator() { |
| 213 return "\\\\"; | 213 return "\\\\"; |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 File::StdioHandleType File::GetStdioHandleType(int fd) { | 217 File::StdioHandleType File::GetStdioHandleType(int fd) { |
| 218 // Treat all stdio handles as pipes. The Windows event handler and | 218 // Treat all stdio handles as pipes. The Windows event handler and |
| 219 // socket code will handle the different handle types. | 219 // socket code will handle the different handle types. |
| 220 return kPipe; | 220 return kPipe; |
| 221 } | 221 } |
| OLD | NEW |