| 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 BIN_FILE_H_ | 5 #ifndef BIN_FILE_H_ |
| 6 #define BIN_FILE_H_ | 6 #define 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 void DeleteWeakHandle(Dart_Isolate isolate) { | 150 void DeleteWeakHandle(Dart_Isolate isolate) { |
| 151 Dart_DeleteWeakPersistentHandle(isolate, weak_handle_); | 151 Dart_DeleteWeakPersistentHandle(isolate, weak_handle_); |
| 152 weak_handle_ = NULL; | 152 weak_handle_ = NULL; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Open the file with the given path. The file is always opened for | 155 // Open the file with the given path. The file is always opened for |
| 156 // reading. If mode contains kWrite the file is opened for both | 156 // reading. If mode contains kWrite the file is opened for both |
| 157 // reading and writing. If mode contains kWrite and the file does | 157 // reading and writing. If mode contains kWrite and the file does |
| 158 // not exist the file is created. The file is truncated to length 0 if | 158 // not exist the file is created. The file is truncated to length 0 if |
| 159 // mode contains kTruncate. Assumes we are in an API scope. | 159 // mode contains kTruncate. Assumes we are in an API scope. |
| 160 static File* ScopedOpen(const char* path, FileOpenMode mode); | |
| 161 | |
| 162 // Like ScopedOpen(), but no API scope is needed. | |
| 163 static File* Open(const char* path, FileOpenMode mode); | 160 static File* Open(const char* path, FileOpenMode mode); |
| 164 | 161 |
| 165 // Caution! On Windows, the static functions below may call | |
| 166 // Dart_ScopeAllocate() to do string conversions! If you call these functions | |
| 167 // without a scope, they will fail on Windows! | |
| 168 | |
| 169 // Create a file object for the specified stdio file descriptor | 162 // Create a file object for the specified stdio file descriptor |
| 170 // (stdin, stout or stderr). | 163 // (stdin, stout or stderr). |
| 171 static File* OpenStdio(int fd); | 164 static File* OpenStdio(int fd); |
| 172 | 165 |
| 173 static bool Exists(const char* path); | 166 static bool Exists(const char* path); |
| 174 static bool Create(const char* path); | 167 static bool Create(const char* path); |
| 175 static bool CreateLink(const char* path, const char* target); | 168 static bool CreateLink(const char* path, const char* target); |
| 176 static bool Delete(const char* path); | 169 static bool Delete(const char* path); |
| 177 static bool DeleteLink(const char* path); | 170 static bool DeleteLink(const char* path); |
| 178 static bool Rename(const char* old_path, const char* new_path); | 171 static bool Rename(const char* old_path, const char* new_path); |
| 179 static bool RenameLink(const char* old_path, const char* new_path); | 172 static bool RenameLink(const char* old_path, const char* new_path); |
| 180 static bool Copy(const char* old_path, const char* new_path); | 173 static bool Copy(const char* old_path, const char* new_path); |
| 181 static int64_t LengthFromPath(const char* path); | 174 static int64_t LengthFromPath(const char* path); |
| 182 static void Stat(const char* path, int64_t* data); | 175 static void Stat(const char* path, int64_t* data); |
| 183 static time_t LastModified(const char* path); | 176 static time_t LastModified(const char* path); |
| 184 static const char* LinkTarget(const char* pathname); | |
| 185 static bool IsAbsolutePath(const char* path); | 177 static bool IsAbsolutePath(const char* path); |
| 186 static const char* GetCanonicalPath(const char* path); | |
| 187 static const char* PathSeparator(); | 178 static const char* PathSeparator(); |
| 188 static const char* StringEscapedPathSeparator(); | 179 static const char* StringEscapedPathSeparator(); |
| 189 static Type GetType(const char* path, bool follow_links); | 180 static Type GetType(const char* path, bool follow_links); |
| 190 static Identical AreIdentical(const char* file_1, const char* file_2); | 181 static Identical AreIdentical(const char* file_1, const char* file_2); |
| 191 static StdioHandleType GetStdioHandleType(int fd); | 182 static StdioHandleType GetStdioHandleType(int fd); |
| 192 | 183 |
| 184 // LinkTarget and GetCanonicalPath may call Dart_ScopeAllocate. |
| 185 static const char* LinkTarget(const char* pathname); |
| 186 static const char* GetCanonicalPath(const char* path); |
| 187 |
| 193 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode); | 188 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode); |
| 194 | 189 |
| 195 static CObject* ExistsRequest(const CObjectArray& request); | 190 static CObject* ExistsRequest(const CObjectArray& request); |
| 196 static CObject* CreateRequest(const CObjectArray& request); | 191 static CObject* CreateRequest(const CObjectArray& request); |
| 197 static CObject* DeleteRequest(const CObjectArray& request); | 192 static CObject* DeleteRequest(const CObjectArray& request); |
| 198 static CObject* RenameRequest(const CObjectArray& request); | 193 static CObject* RenameRequest(const CObjectArray& request); |
| 199 static CObject* CopyRequest(const CObjectArray& request); | 194 static CObject* CopyRequest(const CObjectArray& request); |
| 200 static CObject* OpenRequest(const CObjectArray& request); | 195 static CObject* OpenRequest(const CObjectArray& request); |
| 201 static CObject* ResolveSymbolicLinksRequest(const CObjectArray& request); | 196 static CObject* ResolveSymbolicLinksRequest(const CObjectArray& request); |
| 202 static CObject* CloseRequest(const CObjectArray& request); | 197 static CObject* CloseRequest(const CObjectArray& request); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 Dart_WeakPersistentHandle weak_handle_; | 237 Dart_WeakPersistentHandle weak_handle_; |
| 243 | 238 |
| 244 friend class ReferenceCounted<File>; | 239 friend class ReferenceCounted<File>; |
| 245 DISALLOW_COPY_AND_ASSIGN(File); | 240 DISALLOW_COPY_AND_ASSIGN(File); |
| 246 }; | 241 }; |
| 247 | 242 |
| 248 } // namespace bin | 243 } // namespace bin |
| 249 } // namespace dart | 244 } // namespace dart |
| 250 | 245 |
| 251 #endif // BIN_FILE_H_ | 246 #endif // BIN_FILE_H_ |
| OLD | NEW |