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

Side by Side Diff: runtime/bin/file_patch.dart

Issue 48613002: Add 'isDir' to FileSystemEvent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge with master Created 7 years, 1 month 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 | « no previous file | runtime/bin/file_system_watcher.h » ('j') | sdk/lib/io/file_system_entity.dart » ('J')
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 patch class _File { 5 patch class _File {
6 /* patch */ static _exists(String path) native "File_Exists"; 6 /* patch */ static _exists(String path) native "File_Exists";
7 /* patch */ static _create(String path) native "File_Create"; 7 /* patch */ static _create(String path) native "File_Create";
8 /* patch */ static _createLink(String path, String target) 8 /* patch */ static _createLink(String path, String target)
9 native "File_CreateLink"; 9 native "File_CreateLink";
10 /* patch */ static _linkTarget(String path) native "File_LinkTarget"; 10 /* patch */ static _linkTarget(String path) native "File_LinkTarget";
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 var pair = {}; 82 var pair = {};
83 if (event == RawSocketEvent.READ) { 83 if (event == RawSocketEvent.READ) {
84 String getPath(event) { 84 String getPath(event) {
85 var path = _path; 85 var path = _path;
86 if (event[2] != null) { 86 if (event[2] != null) {
87 path += Platform.pathSeparator; 87 path += Platform.pathSeparator;
88 path += event[2]; 88 path += event[2];
89 } 89 }
90 return path; 90 return path;
91 } 91 }
92 bool getIsDir(event) {
93 if (Platform.isWindows) {
94 // Windows does not get 'isDir' as part of the event.
95 return FileSystemEntity.typeSync(path) ==
96 FileSystemEntityType.DIRECTORY;
Bill Hesse 2013/10/28 16:30:13 This is exactly static FileSystemEntity.isDirector
Anders Johnsen 2013/10/28 16:43:14 Done.
97 }
98 return (event[0] & FileSystemEvent._IS_DIR) != 0;
99 }
92 void add(event) { 100 void add(event) {
93 if ((event.type & _events) == 0) return; 101 if ((event.type & _events) == 0) return;
94 events.add(event); 102 events.add(event);
95 } 103 }
96 void rewriteMove(event) { 104 void rewriteMove(event, isDir) {
97 if (event[3]) { 105 if (event[3]) {
98 add(new FileSystemCreateEvent._(getPath(event))); 106 add(new FileSystemCreateEvent._(getPath(event), isDir));
99 } else { 107 } else {
100 add(new FileSystemDeleteEvent._(getPath(event))); 108 add(new FileSystemDeleteEvent._(getPath(event), isDir));
101 } 109 }
102 } 110 }
103 while (socket.available() > 0) { 111 while (socket.available() > 0) {
104 for (var event in _readEvents()) { 112 for (var event in _readEvents()) {
105 if (event == null) continue; 113 if (event == null) continue;
114 bool isDir = getIsDir(event);
106 var path = getPath(event); 115 var path = getPath(event);
107 if ((event[0] & FileSystemEvent.CREATE) != 0) { 116 if ((event[0] & FileSystemEvent.CREATE) != 0) {
108 add(new FileSystemCreateEvent._(path)); 117 add(new FileSystemCreateEvent._(path, isDir));
109 } 118 }
110 if ((event[0] & FileSystemEvent.MODIFY) != 0) { 119 if ((event[0] & FileSystemEvent.MODIFY) != 0) {
111 add(new FileSystemModifyEvent._(path, true)); 120 add(new FileSystemModifyEvent._(path, isDir, true));
112 } 121 }
113 if ((event[0] & FileSystemEvent._MODIFY_ATTRIBUTES) != 0) { 122 if ((event[0] & FileSystemEvent._MODIFY_ATTRIBUTES) != 0) {
114 add(new FileSystemModifyEvent._(path, false)); 123 add(new FileSystemModifyEvent._(path, isDir, false));
115 } 124 }
116 if ((event[0] & FileSystemEvent.MOVE) != 0) { 125 if ((event[0] & FileSystemEvent.MOVE) != 0) {
117 int link = event[1]; 126 int link = event[1];
118 if (link > 0) { 127 if (link > 0) {
119 if (pair.containsKey(link)) { 128 if (pair.containsKey(link)) {
120 events.add( 129 events.add(new FileSystemMoveEvent._(
121 new FileSystemMoveEvent._(getPath(pair[link]), path)); 130 getPath(pair[link]), isDir, path));
122 pair.remove(link); 131 pair.remove(link);
123 } else { 132 } else {
124 pair[link] = event; 133 pair[link] = event;
125 } 134 }
126 } else { 135 } else {
127 rewriteMove(event); 136 rewriteMove(event, isDir);
128 } 137 }
129 } 138 }
130 if ((event[0] & FileSystemEvent.DELETE) != 0) { 139 if ((event[0] & FileSystemEvent.DELETE) != 0) {
131 add(new FileSystemDeleteEvent._(path)); 140 add(new FileSystemDeleteEvent._(path, isDir));
132 } 141 }
133 if ((event[0] & FileSystemEvent._DELETE_SELF) != 0) { 142 if ((event[0] & FileSystemEvent._DELETE_SELF) != 0) {
134 add(new FileSystemDeleteEvent._(path)); 143 add(new FileSystemDeleteEvent._(path, isDir));
135 stop = true; 144 stop = true;
136 } 145 }
137 } 146 }
138 } 147 }
139 for (var event in pair.values) { 148 for (var event in pair.values) {
140 rewriteMove(event); 149 rewriteMove(event, getIsDir(event));
141 } 150 }
142 } else if (event == RawSocketEvent.CLOSED) { 151 } else if (event == RawSocketEvent.CLOSED) {
143 } else if (event == RawSocketEvent.READ_CLOSED) { 152 } else if (event == RawSocketEvent.READ_CLOSED) {
144 } else { 153 } else {
145 assert(false); 154 assert(false);
146 } 155 }
147 if (stop) socket.close(); 156 if (stop) socket.close();
148 return events; 157 return events;
149 }) 158 })
150 .listen(_controller.add, onDone: _cancel); 159 .listen(_controller.add, onDone: _cancel);
(...skipping 14 matching lines...) Expand all
165 174
166 int _watchPath(String path, int events, bool recursive) 175 int _watchPath(String path, int events, bool recursive)
167 native "FileSystemWatcher_WatchPath"; 176 native "FileSystemWatcher_WatchPath";
168 void _unwatchPath() native "FileSystemWatcher_UnwatchPath"; 177 void _unwatchPath() native "FileSystemWatcher_UnwatchPath";
169 List _readEvents() native "FileSystemWatcher_ReadEvents"; 178 List _readEvents() native "FileSystemWatcher_ReadEvents";
170 } 179 }
171 180
172 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) { 181 Uint8List _makeUint8ListView(Uint8List source, int offsetInBytes, int length) {
173 return new Uint8List.view(source.buffer, offsetInBytes, length); 182 return new Uint8List.view(source.buffer, offsetInBytes, length);
174 } 183 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/file_system_watcher.h » ('j') | sdk/lib/io/file_system_entity.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698