| 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_DIRECTORY_H_ | 5 #ifndef BIN_DIRECTORY_H_ |
| 6 #define BIN_DIRECTORY_H_ | 6 #define BIN_DIRECTORY_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/dartutils.h" |
| 9 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| 10 | 11 |
| 12 class DirectoryListing { |
| 13 public: |
| 14 enum Response { |
| 15 kListDirectory = 0, |
| 16 kListFile = 1, |
| 17 kListError = 2, |
| 18 kListDone = 3 |
| 19 }; |
| 20 |
| 21 explicit DirectoryListing(Dart_Port response_port) |
| 22 : response_port_(response_port) {} |
| 23 bool HandleDirectory(char* dir_name); |
| 24 bool HandleFile(char* file_name); |
| 25 bool HandleError(char* message); |
| 26 |
| 27 private: |
| 28 CObjectArray* NewResponse(Response response, char* arg); |
| 29 Dart_Port response_port_; |
| 30 |
| 31 DISALLOW_IMPLICIT_CONSTRUCTORS(DirectoryListing); |
| 32 }; |
| 33 |
| 34 |
| 11 class Directory { | 35 class Directory { |
| 12 public: | 36 public: |
| 13 enum ExistsResult { | 37 enum ExistsResult { |
| 14 UNKNOWN, | 38 UNKNOWN, |
| 15 EXISTS, | 39 EXISTS, |
| 16 DOES_NOT_EXIST | 40 DOES_NOT_EXIST |
| 17 }; | 41 }; |
| 18 | 42 |
| 19 static void List(const char* path, | 43 enum DirectoryRequest { |
| 44 kCreateRequest = 0, |
| 45 kDeleteRequest = 1, |
| 46 kExistsRequest = 2, |
| 47 kCreateTempRequest = 3, |
| 48 kListRequest = 4 |
| 49 }; |
| 50 |
| 51 static bool List(const char* path, |
| 20 bool recursive, | 52 bool recursive, |
| 21 Dart_Port dir_port, | 53 DirectoryListing* listing); |
| 22 Dart_Port file_port, | |
| 23 Dart_Port done_port, | |
| 24 Dart_Port error_port); | |
| 25 | 54 |
| 26 static ExistsResult Exists(const char* path); | 55 static ExistsResult Exists(const char* path); |
| 27 | 56 |
| 28 static bool Create(const char* path); | 57 static bool Create(const char* path); |
| 29 | 58 |
| 30 static int CreateTemp(const char* const_template, | 59 static int CreateTemp(const char* const_template, |
| 31 char** path, | 60 char** path, |
| 32 char* os_error_message, | 61 char* os_error_message, |
| 33 int os_error_message_len); | 62 int os_error_message_len); |
| 34 | 63 |
| 35 static bool Delete(const char* path, bool recursive); | 64 static bool Delete(const char* path, bool recursive); |
| 36 | 65 |
| 37 DISALLOW_ALLOCATION(); | 66 DISALLOW_ALLOCATION(); |
| 38 DISALLOW_IMPLICIT_CONSTRUCTORS(Directory); | 67 DISALLOW_IMPLICIT_CONSTRUCTORS(Directory); |
| 39 }; | 68 }; |
| 40 | 69 |
| 70 |
| 41 #endif // BIN_DIRECTORY_H_ | 71 #endif // BIN_DIRECTORY_H_ |
| OLD | NEW |