| 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 #ifndef BIN_FILE_H_ | 5 #ifndef BIN_FILE_H_ |
| 6 #define BIN_FILE_H_ | 6 #define BIN_FILE_H_ |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // These values have to be kept in sync with the mode values of | 31 // These values have to be kept in sync with the mode values of |
| 32 // FileMode.READ, FileMode.WRITE and FileMode.APPEND in file.dart. | 32 // FileMode.READ, FileMode.WRITE and FileMode.APPEND in file.dart. |
| 33 enum DartFileOpenMode { | 33 enum DartFileOpenMode { |
| 34 kDartRead = 0, | 34 kDartRead = 0, |
| 35 kDartWrite = 1, | 35 kDartWrite = 1, |
| 36 kDartAppend = 2 | 36 kDartAppend = 2 |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 enum Type { |
| 40 kIsFile = 0, |
| 41 kIsDirectory = 1, |
| 42 kIsLink = 2, |
| 43 kDoesNotExist = 3 |
| 44 }; |
| 45 |
| 39 enum StdioHandleType { | 46 enum StdioHandleType { |
| 40 kTerminal = 0, | 47 kTerminal = 0, |
| 41 kPipe = 1, | 48 kPipe = 1, |
| 42 kFile = 2, | 49 kFile = 2, |
| 43 kSocket = 3, | 50 kSocket = 3, |
| 44 kOther = -1 | 51 kOther = -1 |
| 45 }; | 52 }; |
| 46 | 53 |
| 47 enum FileRequest { | 54 enum FileRequest { |
| 48 kExistsRequest = 0, | 55 kExistsRequest = 0, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 static bool Exists(const char* path); | 124 static bool Exists(const char* path); |
| 118 static bool Create(const char* path); | 125 static bool Create(const char* path); |
| 119 static bool Delete(const char* path); | 126 static bool Delete(const char* path); |
| 120 static off_t LengthFromPath(const char* path); | 127 static off_t LengthFromPath(const char* path); |
| 121 static time_t LastModified(const char* path); | 128 static time_t LastModified(const char* path); |
| 122 static bool IsAbsolutePath(const char* path); | 129 static bool IsAbsolutePath(const char* path); |
| 123 static char* GetCanonicalPath(const char* path); | 130 static char* GetCanonicalPath(const char* path); |
| 124 static char* GetContainingDirectory(char* path); | 131 static char* GetContainingDirectory(char* path); |
| 125 static const char* PathSeparator(); | 132 static const char* PathSeparator(); |
| 126 static const char* StringEscapedPathSeparator(); | 133 static const char* StringEscapedPathSeparator(); |
| 134 static Type GetType(const char* path, bool follow_links); |
| 127 static StdioHandleType GetStdioHandleType(int fd); | 135 static StdioHandleType GetStdioHandleType(int fd); |
| 128 | 136 |
| 129 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode); | 137 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode); |
| 130 | 138 |
| 131 static Dart_Port GetServicePort(); | 139 static Dart_Port GetServicePort(); |
| 132 | 140 |
| 133 private: | 141 private: |
| 134 explicit File(FileHandle* handle) : handle_(handle) { } | 142 explicit File(FileHandle* handle) : handle_(handle) { } |
| 135 void Close(); | 143 void Close(); |
| 136 | 144 |
| 137 static const int kClosedFd = -1; | 145 static const int kClosedFd = -1; |
| 138 | 146 |
| 139 // FileHandle is an OS specific class which stores data about the file. | 147 // FileHandle is an OS specific class which stores data about the file. |
| 140 FileHandle* handle_; // OS specific handle for the file. | 148 FileHandle* handle_; // OS specific handle for the file. |
| 141 | 149 |
| 142 static NativeService file_service_; | 150 static NativeService file_service_; |
| 143 | 151 |
| 144 DISALLOW_COPY_AND_ASSIGN(File); | 152 DISALLOW_COPY_AND_ASSIGN(File); |
| 145 }; | 153 }; |
| 146 | 154 |
| 147 #endif // BIN_FILE_H_ | 155 #endif // BIN_FILE_H_ |
| OLD | NEW |