| 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> |
| 11 #include <sys/types.h> | 11 #include <sys/types.h> |
| 12 | 12 |
| 13 #include "bin/builtin.h" | 13 #include "bin/builtin.h" |
| 14 #include "bin/dartutils.h" | 14 #include "bin/dartutils.h" |
| 15 #include "bin/log.h" | 15 #include "bin/log.h" |
| 16 #include "bin/namespace.h" |
| 16 #include "bin/reference_counting.h" | 17 #include "bin/reference_counting.h" |
| 17 | 18 |
| 18 namespace dart { | 19 namespace dart { |
| 19 namespace bin { | 20 namespace bin { |
| 20 | 21 |
| 21 // Forward declaration. | 22 // Forward declaration. |
| 22 class FileHandle; | 23 class FileHandle; |
| 23 | 24 |
| 24 class MappedMemory { | 25 class MappedMemory { |
| 25 public: | 26 public: |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 void DeleteWeakHandle(Dart_Isolate isolate) { | 166 void DeleteWeakHandle(Dart_Isolate isolate) { |
| 166 Dart_DeleteWeakPersistentHandle(isolate, weak_handle_); | 167 Dart_DeleteWeakPersistentHandle(isolate, weak_handle_); |
| 167 weak_handle_ = NULL; | 168 weak_handle_ = NULL; |
| 168 } | 169 } |
| 169 | 170 |
| 170 // Open the file with the given path. The file is always opened for | 171 // Open the file with the given path. The file is always opened for |
| 171 // reading. If mode contains kWrite the file is opened for both | 172 // reading. If mode contains kWrite the file is opened for both |
| 172 // reading and writing. If mode contains kWrite and the file does | 173 // reading and writing. If mode contains kWrite and the file does |
| 173 // not exist the file is created. The file is truncated to length 0 if | 174 // not exist the file is created. The file is truncated to length 0 if |
| 174 // mode contains kTruncate. Assumes we are in an API scope. | 175 // mode contains kTruncate. Assumes we are in an API scope. |
| 175 static File* Open(const char* path, FileOpenMode mode); | 176 static File* Open( |
| 177 Namespace* namespc, const char* path, FileOpenMode mode); |
| 176 | 178 |
| 177 // Create a file object for the specified stdio file descriptor | 179 // Create a file object for the specified stdio file descriptor |
| 178 // (stdin, stout or stderr). | 180 // (stdin, stout or stderr). |
| 179 static File* OpenStdio(int fd); | 181 static File* OpenStdio(int fd); |
| 180 | 182 |
| 181 static bool Exists(const char* path); | 183 static bool Exists( |
| 182 static bool Create(const char* path); | 184 Namespace* namespc, const char* path); |
| 183 static bool CreateLink(const char* path, const char* target); | 185 static bool Create( |
| 184 static bool Delete(const char* path); | 186 Namespace* namespc, const char* path); |
| 185 static bool DeleteLink(const char* path); | 187 static bool CreateLink( |
| 186 static bool Rename(const char* old_path, const char* new_path); | 188 Namespace* namespc, const char* path, const char* target); |
| 187 static bool RenameLink(const char* old_path, const char* new_path); | 189 static bool Delete( |
| 188 static bool Copy(const char* old_path, const char* new_path); | 190 Namespace* namespc, const char* path); |
| 189 static int64_t LengthFromPath(const char* path); | 191 static bool DeleteLink( |
| 190 static void Stat(const char* path, int64_t* data); | 192 Namespace* namespc, const char* path); |
| 191 static time_t LastModified(const char* path); | 193 static bool Rename( |
| 192 static bool SetLastModified(const char* path, int64_t millis); | 194 Namespace* namespc, const char* old_path, const char* new_path); |
| 193 static time_t LastAccessed(const char* path); | 195 static bool RenameLink( |
| 194 static bool SetLastAccessed(const char* path, int64_t millis); | 196 Namespace* namespc, const char* old_path, const char* new_path); |
| 197 static bool Copy( |
| 198 Namespace* namespc, const char* old_path, const char* new_path); |
| 199 static int64_t LengthFromPath( |
| 200 Namespace* namespc, const char* path); |
| 201 static void Stat( |
| 202 Namespace* namespc, const char* path, int64_t* data); |
| 203 static time_t LastModified( |
| 204 Namespace* namespc, const char* path); |
| 205 static bool SetLastModified( |
| 206 Namespace* namespc, const char* path, int64_t millis); |
| 207 static time_t LastAccessed( |
| 208 Namespace* namespc, const char* path); |
| 209 static bool SetLastAccessed( |
| 210 Namespace* namespc, const char* path, int64_t millis); |
| 195 static bool IsAbsolutePath(const char* path); | 211 static bool IsAbsolutePath(const char* path); |
| 196 static const char* PathSeparator(); | 212 static const char* PathSeparator(); |
| 197 static const char* StringEscapedPathSeparator(); | 213 static const char* StringEscapedPathSeparator(); |
| 198 static Type GetType(const char* path, bool follow_links); | 214 static Type GetType( |
| 199 static Identical AreIdentical(const char* file_1, const char* file_2); | 215 Namespace* namespc, const char* path, bool follow_links); |
| 216 static Identical AreIdentical( |
| 217 Namespace* namespc, const char* file_1, const char* file_2); |
| 200 static StdioHandleType GetStdioHandleType(int fd); | 218 static StdioHandleType GetStdioHandleType(int fd); |
| 201 | 219 |
| 202 // LinkTarget and GetCanonicalPath may call Dart_ScopeAllocate. | 220 // LinkTarget, GetCanonicalPath, and ReadLink may call Dart_ScopeAllocate. |
| 203 static const char* LinkTarget(const char* pathname); | 221 static const char* LinkTarget( |
| 204 static const char* GetCanonicalPath(const char* path); | 222 Namespace* namespc, const char* pathname); |
| 223 static const char* GetCanonicalPath( |
| 224 Namespace* namespc, const char* path); |
| 225 // Link LinkTarget, but pathname must be absolute. |
| 226 static const char* ReadLink(const char* pathname); |
| 205 | 227 |
| 206 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode); | 228 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode); |
| 207 | 229 |
| 208 static CObject* ExistsRequest(const CObjectArray& request); | 230 static CObject* ExistsRequest(const CObjectArray& request); |
| 209 static CObject* CreateRequest(const CObjectArray& request); | 231 static CObject* CreateRequest(const CObjectArray& request); |
| 210 static CObject* DeleteRequest(const CObjectArray& request); | 232 static CObject* DeleteRequest(const CObjectArray& request); |
| 211 static CObject* RenameRequest(const CObjectArray& request); | 233 static CObject* RenameRequest(const CObjectArray& request); |
| 212 static CObject* CopyRequest(const CObjectArray& request); | 234 static CObject* CopyRequest(const CObjectArray& request); |
| 213 static CObject* OpenRequest(const CObjectArray& request); | 235 static CObject* OpenRequest(const CObjectArray& request); |
| 214 static CObject* ResolveSymbolicLinksRequest(const CObjectArray& request); | 236 static CObject* ResolveSymbolicLinksRequest(const CObjectArray& request); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 Dart_WeakPersistentHandle weak_handle_; | 278 Dart_WeakPersistentHandle weak_handle_; |
| 257 | 279 |
| 258 friend class ReferenceCounted<File>; | 280 friend class ReferenceCounted<File>; |
| 259 DISALLOW_COPY_AND_ASSIGN(File); | 281 DISALLOW_COPY_AND_ASSIGN(File); |
| 260 }; | 282 }; |
| 261 | 283 |
| 262 } // namespace bin | 284 } // namespace bin |
| 263 } // namespace dart | 285 } // namespace dart |
| 264 | 286 |
| 265 #endif // RUNTIME_BIN_FILE_H_ | 287 #endif // RUNTIME_BIN_FILE_H_ |
| OLD | NEW |