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

Side by Side Diff: sdk/lib/io/directory_impl.dart

Issue 19263003: Add FileSystemWatcher class to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix android socket. Created 7 years, 3 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/socket_win.cc ('k') | sdk/lib/io/file_impl.dart » ('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 part of dart.io; 5 part of dart.io;
6 6
7 class _Directory implements Directory { 7 class _Directory extends FileSystemEntity implements Directory {
8 static const CREATE_REQUEST = 0; 8 static const CREATE_REQUEST = 0;
9 static const DELETE_REQUEST = 1; 9 static const DELETE_REQUEST = 1;
10 static const EXISTS_REQUEST = 2; 10 static const EXISTS_REQUEST = 2;
11 static const CREATE_TEMP_REQUEST = 3; 11 static const CREATE_TEMP_REQUEST = 3;
12 static const LIST_START_REQUEST = 4; 12 static const LIST_START_REQUEST = 4;
13 static const LIST_NEXT_REQUEST = 5; 13 static const LIST_NEXT_REQUEST = 5;
14 static const LIST_STOP_REQUEST = 6; 14 static const LIST_STOP_REQUEST = 6;
15 static const RENAME_REQUEST = 7; 15 static const RENAME_REQUEST = 7;
16 16
17 final String path; 17 final String path;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (newPath is !String) { 222 if (newPath is !String) {
223 throw new ArgumentError(); 223 throw new ArgumentError();
224 } 224 }
225 var result = _rename(path, newPath); 225 var result = _rename(path, newPath);
226 if (result is OSError) { 226 if (result is OSError) {
227 throw new DirectoryException("Rename failed", path, result); 227 throw new DirectoryException("Rename failed", path, result);
228 } 228 }
229 return new Directory(newPath); 229 return new Directory(newPath);
230 } 230 }
231 231
232 static String _trimTrailingPathSeparators(String path) {
233 // Don't handle argument errors here.
234 if (path is! String) return path;
235 if (Platform.operatingSystem == 'windows') {
236 while (path.length > 1 &&
237 (path.endsWith(Platform.pathSeparator) ||
238 path.endsWith('/'))) {
239 path = path.substring(0, path.length - 1);
240 }
241 } else {
242 while (path.length > 1 && path.endsWith(Platform.pathSeparator)) {
243 path = path.substring(0, path.length - 1);
244 }
245 }
246 return path;
247 }
248
249 Stream<FileSystemEntity> list({bool recursive: false, 232 Stream<FileSystemEntity> list({bool recursive: false,
250 bool followLinks: true}) { 233 bool followLinks: true}) {
251 return new _AsyncDirectoryLister(_trimTrailingPathSeparators(path), 234 return new _AsyncDirectoryLister(
252 recursive, 235 FileSystemEntity._trimTrailingPathSeparators(path),
253 followLinks).stream; 236 recursive,
237 followLinks).stream;
254 } 238 }
255 239
256 List listSync({bool recursive: false, bool followLinks: true}) { 240 List listSync({bool recursive: false, bool followLinks: true}) {
257 if (recursive is! bool || followLinks is! bool) { 241 if (recursive is! bool || followLinks is! bool) {
258 throw new ArgumentError(); 242 throw new ArgumentError();
259 } 243 }
260 return _list(_trimTrailingPathSeparators(path), recursive, followLinks); 244 return _list(
245 FileSystemEntity._trimTrailingPathSeparators(path),
246 recursive,
247 followLinks);
261 } 248 }
262 249
263 String toString() => "Directory: '$path'"; 250 String toString() => "Directory: '$path'";
264 251
265 bool _isErrorResponse(response) { 252 bool _isErrorResponse(response) {
266 return response is List && response[0] != _SUCCESS_RESPONSE; 253 return response is List && response[0] != _SUCCESS_RESPONSE;
267 } 254 }
268 255
269 _exceptionOrErrorFromResponse(response, String message) { 256 _exceptionOrErrorFromResponse(response, String message) {
270 assert(_isErrorResponse(response)); 257 assert(_isErrorResponse(response));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 controller.addError( 399 controller.addError(
413 new DirectoryException("Directory listing failed", 400 new DirectoryException("Directory listing failed",
414 errorPath, 401 errorPath,
415 err)); 402 err));
416 } else { 403 } else {
417 controller.addError( 404 controller.addError(
418 new DirectoryException("Internal error")); 405 new DirectoryException("Internal error"));
419 } 406 }
420 } 407 }
421 } 408 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698