Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: runtime/bin/directory.h

Issue 12638039: dart:io | Add "followLinks" optional parameter to Directory.list, let it return Link objects when f… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Switch from Stream.reduce to Completer in link_test. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/directory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bin/dartutils.h"
10 #include "bin/native_service.h" 10 #include "bin/native_service.h"
11 #include "platform/globals.h" 11 #include "platform/globals.h"
12 #include "platform/thread.h" 12 #include "platform/thread.h"
13 13
14 class DirectoryListing { 14 class DirectoryListing {
15 public: 15 public:
16 virtual ~DirectoryListing() {} 16 virtual ~DirectoryListing() {}
17 virtual bool HandleDirectory(char* dir_name) = 0; 17 virtual bool HandleDirectory(char* dir_name) = 0;
18 virtual bool HandleFile(char* file_name) = 0; 18 virtual bool HandleFile(char* file_name) = 0;
19 virtual bool HandleLink(char* file_name) = 0;
19 virtual bool HandleError(const char* dir_name) = 0; 20 virtual bool HandleError(const char* dir_name) = 0;
20 }; 21 };
21 22
22 23
23 class AsyncDirectoryListing : public DirectoryListing { 24 class AsyncDirectoryListing : public DirectoryListing {
24 public: 25 public:
25 enum Response { 26 enum Response {
26 kListFile = 0, 27 kListFile = 0,
27 kListDirectory = 1, 28 kListDirectory = 1,
28 kListError = 2, 29 kListLink = 2,
29 kListDone = 3 30 kListError = 3,
31 kListDone = 4
30 }; 32 };
31 33
32 explicit AsyncDirectoryListing(Dart_Port response_port) 34 explicit AsyncDirectoryListing(Dart_Port response_port)
33 : response_port_(response_port) {} 35 : response_port_(response_port) {}
34 virtual ~AsyncDirectoryListing() {} 36 virtual ~AsyncDirectoryListing() {}
35 virtual bool HandleDirectory(char* dir_name); 37 virtual bool HandleDirectory(char* dir_name);
36 virtual bool HandleFile(char* file_name); 38 virtual bool HandleFile(char* file_name);
39 virtual bool HandleLink(char* file_name);
37 virtual bool HandleError(const char* dir_name); 40 virtual bool HandleError(const char* dir_name);
38 41
39 private: 42 private:
40 CObjectArray* NewResponse(Response response, char* arg); 43 CObjectArray* NewResponse(Response response, char* arg);
41 Dart_Port response_port_; 44 Dart_Port response_port_;
42 45
43 DISALLOW_IMPLICIT_CONSTRUCTORS(AsyncDirectoryListing); 46 DISALLOW_IMPLICIT_CONSTRUCTORS(AsyncDirectoryListing);
44 }; 47 };
45 48
46 49
47 class SyncDirectoryListing: public DirectoryListing { 50 class SyncDirectoryListing: public DirectoryListing {
48 public: 51 public:
49 explicit SyncDirectoryListing(Dart_Handle results) 52 explicit SyncDirectoryListing(Dart_Handle results)
50 : results_(results) { 53 : results_(results) {
51 add_string_ = DartUtils::NewString("add"); 54 add_string_ = DartUtils::NewString("add");
52 directory_class_ = 55 directory_class_ =
53 DartUtils::GetDartClass(DartUtils::kIOLibURL, "Directory"); 56 DartUtils::GetDartClass(DartUtils::kIOLibURL, "Directory");
54 file_class_ = 57 file_class_ =
55 DartUtils::GetDartClass(DartUtils::kIOLibURL, "File"); 58 DartUtils::GetDartClass(DartUtils::kIOLibURL, "File");
59 link_class_ =
60 DartUtils::GetDartClass(DartUtils::kIOLibURL, "Link");
56 } 61 }
57 virtual ~SyncDirectoryListing() {} 62 virtual ~SyncDirectoryListing() {}
58 virtual bool HandleDirectory(char* dir_name); 63 virtual bool HandleDirectory(char* dir_name);
59 virtual bool HandleFile(char* file_name); 64 virtual bool HandleFile(char* file_name);
65 virtual bool HandleLink(char* file_name);
60 virtual bool HandleError(const char* dir_name); 66 virtual bool HandleError(const char* dir_name);
61 67
62 private: 68 private:
63 Dart_Handle results_; 69 Dart_Handle results_;
64 Dart_Handle add_string_; 70 Dart_Handle add_string_;
65 Dart_Handle directory_class_; 71 Dart_Handle directory_class_;
66 Dart_Handle file_class_; 72 Dart_Handle file_class_;
73 Dart_Handle link_class_;
67 74
68 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncDirectoryListing); 75 DISALLOW_IMPLICIT_CONSTRUCTORS(SyncDirectoryListing);
69 }; 76 };
70 77
71 78
72 class Directory { 79 class Directory {
73 public: 80 public:
74 enum ExistsResult { 81 enum ExistsResult {
75 UNKNOWN, 82 UNKNOWN,
76 EXISTS, 83 EXISTS,
77 DOES_NOT_EXIST 84 DOES_NOT_EXIST
78 }; 85 };
79 86
80 // This enum must be kept in sync with the request values in 87 // This enum must be kept in sync with the request values in
81 // directory_impl.dart. 88 // directory_impl.dart.
82 enum DirectoryRequest { 89 enum DirectoryRequest {
83 kCreateRequest = 0, 90 kCreateRequest = 0,
84 kDeleteRequest = 1, 91 kDeleteRequest = 1,
85 kExistsRequest = 2, 92 kExistsRequest = 2,
86 kCreateTempRequest = 3, 93 kCreateTempRequest = 3,
87 kListRequest = 4, 94 kListRequest = 4,
88 kRenameRequest = 5 95 kRenameRequest = 5
89 }; 96 };
90 97
91 static bool List(const char* path, 98 static bool List(const char* path,
92 bool recursive, 99 bool recursive,
100 bool follow_links,
93 DirectoryListing* listing); 101 DirectoryListing* listing);
94 static ExistsResult Exists(const char* path); 102 static ExistsResult Exists(const char* path);
95 static char* Current(); 103 static char* Current();
96 static bool Create(const char* path); 104 static bool Create(const char* path);
97 static char* CreateTemp(const char* const_template); 105 static char* CreateTemp(const char* const_template);
98 static bool Delete(const char* path, bool recursive); 106 static bool Delete(const char* path, bool recursive);
99 static bool Rename(const char* path, const char* new_path); 107 static bool Rename(const char* path, const char* new_path);
100 static Dart_Port GetServicePort(); 108 static Dart_Port GetServicePort();
101 109
102 private: 110 private:
103 static NativeService directory_service_; 111 static NativeService directory_service_;
104 112
105 DISALLOW_ALLOCATION(); 113 DISALLOW_ALLOCATION();
106 DISALLOW_IMPLICIT_CONSTRUCTORS(Directory); 114 DISALLOW_IMPLICIT_CONSTRUCTORS(Directory);
107 }; 115 };
108 116
109 117
110 #endif // BIN_DIRECTORY_H_ 118 #endif // BIN_DIRECTORY_H_
OLDNEW
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/directory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698