OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #ifndef RUNTIME_BIN_FILE_H_ | 5 #ifndef RUNTIME_BIN_FILE_H_ |
6 #define RUNTIME_BIN_FILE_H_ | 6 #define RUNTIME_BIN_FILE_H_ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // FileMode.READ, FileMode.WRITE, FileMode.APPEND, | 53 // FileMode.READ, FileMode.WRITE, FileMode.APPEND, |
54 // FileMode.WRITE_ONLY and FileMode.WRITE_ONLY_APPEND in file.dart. | 54 // FileMode.WRITE_ONLY and FileMode.WRITE_ONLY_APPEND in file.dart. |
55 enum DartFileOpenMode { | 55 enum DartFileOpenMode { |
56 kDartRead = 0, | 56 kDartRead = 0, |
57 kDartWrite = 1, | 57 kDartWrite = 1, |
58 kDartAppend = 2, | 58 kDartAppend = 2, |
59 kDartWriteOnly = 3, | 59 kDartWriteOnly = 3, |
60 kDartWriteOnlyAppend = 4 | 60 kDartWriteOnlyAppend = 4 |
61 }; | 61 }; |
62 | 62 |
63 // These values have to be kept in sync with the values of | |
64 // _FileTranslation.text and _FileTranslation.binary in file_impl.dart | |
65 enum DartFileTranslation { | |
66 kText = 0, | |
67 kBinary = 1, | |
68 }; | |
69 | |
70 enum Type { kIsFile = 0, kIsDirectory = 1, kIsLink = 2, kDoesNotExist = 3 }; | 63 enum Type { kIsFile = 0, kIsDirectory = 1, kIsLink = 2, kDoesNotExist = 3 }; |
71 | 64 |
72 enum Identical { kIdentical = 0, kDifferent = 1, kError = 2 }; | 65 enum Identical { kIdentical = 0, kDifferent = 1, kError = 2 }; |
73 | 66 |
74 enum StdioHandleType { | 67 enum StdioHandleType { |
75 kTerminal = 0, | 68 kTerminal = 0, |
76 kPipe = 1, | 69 kPipe = 1, |
77 kFile = 2, | 70 kFile = 2, |
78 kSocket = 3, | 71 kSocket = 3, |
79 kOther = 4 | 72 kOther = 4 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // be determined (e.g. not seekable device). | 128 // be determined (e.g. not seekable device). |
136 int64_t Length(); | 129 int64_t Length(); |
137 | 130 |
138 // Get the current position in the file. | 131 // Get the current position in the file. |
139 // Returns a negative value if position cannot be determined. | 132 // Returns a negative value if position cannot be determined. |
140 int64_t Position(); | 133 int64_t Position(); |
141 | 134 |
142 // Set the byte position in the file. | 135 // Set the byte position in the file. |
143 bool SetPosition(int64_t position); | 136 bool SetPosition(int64_t position); |
144 | 137 |
145 // Set the translation mode of the file. This is currently a no-op unless the | |
146 // file is for a terminal on Windows. | |
147 void SetTranslation(DartFileTranslation translation); | |
148 | |
149 // Truncate (or extend) the file to the given length in bytes. | 138 // Truncate (or extend) the file to the given length in bytes. |
150 bool Truncate(int64_t length); | 139 bool Truncate(int64_t length); |
151 | 140 |
152 // Flush contents of file. | 141 // Flush contents of file. |
153 bool Flush(); | 142 bool Flush(); |
154 | 143 |
155 // Lock range of a file. | 144 // Lock range of a file. |
156 bool Lock(LockType lock, int64_t start, int64_t end); | 145 bool Lock(LockType lock, int64_t start, int64_t end); |
157 | 146 |
158 // Returns whether the file has been closed. | 147 // Returns whether the file has been closed. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 Dart_WeakPersistentHandle weak_handle_; | 256 Dart_WeakPersistentHandle weak_handle_; |
268 | 257 |
269 friend class ReferenceCounted<File>; | 258 friend class ReferenceCounted<File>; |
270 DISALLOW_COPY_AND_ASSIGN(File); | 259 DISALLOW_COPY_AND_ASSIGN(File); |
271 }; | 260 }; |
272 | 261 |
273 } // namespace bin | 262 } // namespace bin |
274 } // namespace dart | 263 } // namespace dart |
275 | 264 |
276 #endif // RUNTIME_BIN_FILE_H_ | 265 #endif // RUNTIME_BIN_FILE_H_ |
OLD | NEW |