| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 class FileSystemEntityType { | 7 class FileSystemEntityType { |
| 8 static const FILE = const FileSystemEntityType._internal(0); | 8 static const FILE = const FileSystemEntityType._internal(0); |
| 9 static const DIRECTORY = const FileSystemEntityType._internal(1); | 9 static const DIRECTORY = const FileSystemEntityType._internal(1); |
| 10 static const LINK = const FileSystemEntityType._internal(2); | 10 static const LINK = const FileSystemEntityType._internal(2); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Asynchronously calls the operating system's stat() function on [path]. | 67 * Asynchronously calls the operating system's stat() function on [path]. |
| 68 * Returns a Future which completes with a [FileStat] object containing | 68 * Returns a Future which completes with a [FileStat] object containing |
| 69 * the data returned by stat(). | 69 * the data returned by stat(). |
| 70 * If the call fails, completes the future with a [FileStat] object with | 70 * If the call fails, completes the future with a [FileStat] object with |
| 71 * .type set to FileSystemEntityType.NOT_FOUND and the other fields invalid. | 71 * .type set to FileSystemEntityType.NOT_FOUND and the other fields invalid. |
| 72 */ | 72 */ |
| 73 static Future<FileStat> stat(String path) { | 73 static Future<FileStat> stat(String path) { |
| 74 return IOService.dispatch(FILE_STAT, [path]).then((response) { | 74 return _IOService.dispatch(_FILE_STAT, [path]).then((response) { |
| 75 if (_isErrorResponse(response)) { | 75 if (_isErrorResponse(response)) { |
| 76 throw _exceptionFromResponse(response, | 76 throw _exceptionFromResponse(response, |
| 77 "Error getting stat", | 77 "Error getting stat", |
| 78 path); | 78 path); |
| 79 } | 79 } |
| 80 // Unwrap the real list from the "I'm not an error" wrapper. | 80 // Unwrap the real list from the "I'm not an error" wrapper. |
| 81 List data = response[1]; | 81 List data = response[1]; |
| 82 return new FileStat._internal( | 82 return new FileStat._internal( |
| 83 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000), | 83 new DateTime.fromMillisecondsSinceEpoch(data[_CHANGED_TIME] * 1000), |
| 84 new DateTime.fromMillisecondsSinceEpoch(data[_MODIFIED_TIME] * 1000), | 84 new DateTime.fromMillisecondsSinceEpoch(data[_MODIFIED_TIME] * 1000), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 * | 229 * |
| 230 * On Windows, symbolic links are resolved to their target before applying | 230 * On Windows, symbolic links are resolved to their target before applying |
| 231 * a '..' that follows, and on other platforms, the '..' is applied to the | 231 * a '..' that follows, and on other platforms, the '..' is applied to the |
| 232 * symbolic link without resolving it. The second behavior can be emulated | 232 * symbolic link without resolving it. The second behavior can be emulated |
| 233 * on Windows by processing any '..' segments before calling | 233 * on Windows by processing any '..' segments before calling |
| 234 * [resolveSymbolicLinks]. One way of doing this is with the URI class: | 234 * [resolveSymbolicLinks]. One way of doing this is with the URI class: |
| 235 * [:new Uri.parse('.').resolveUri(new Uri.file(input)).toFilePath();], | 235 * [:new Uri.parse('.').resolveUri(new Uri.file(input)).toFilePath();], |
| 236 * since [resolve] removes '..' segments. | 236 * since [resolve] removes '..' segments. |
| 237 */ | 237 */ |
| 238 Future<String> resolveSymbolicLinks() { | 238 Future<String> resolveSymbolicLinks() { |
| 239 return IOService.dispatch(FILE_RESOLVE_SYMBOLIC_LINKS, [path]) | 239 return _IOService.dispatch(_FILE_RESOLVE_SYMBOLIC_LINKS, [path]) |
| 240 .then((response) { | 240 .then((response) { |
| 241 if (_isErrorResponse(response)) { | 241 if (_isErrorResponse(response)) { |
| 242 throw _exceptionFromResponse(response, | 242 throw _exceptionFromResponse(response, |
| 243 "Cannot resolve symbolic links", | 243 "Cannot resolve symbolic links", |
| 244 path); | 244 path); |
| 245 } | 245 } |
| 246 return response; | 246 return response; |
| 247 }); | 247 }); |
| 248 } | 248 } |
| 249 | 249 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 * | 374 * |
| 375 * Comparing a link to its target returns false, as does comparing two links | 375 * Comparing a link to its target returns false, as does comparing two links |
| 376 * that point to the same target. To check the target of a link, use | 376 * that point to the same target. To check the target of a link, use |
| 377 * Link.target explicitly to fetch it. Directory links appearing | 377 * Link.target explicitly to fetch it. Directory links appearing |
| 378 * inside a path are followed, though, to find the file system object. | 378 * inside a path are followed, though, to find the file system object. |
| 379 * | 379 * |
| 380 * Completes the returned Future with an error if one of the paths points | 380 * Completes the returned Future with an error if one of the paths points |
| 381 * to an object that does not exist. | 381 * to an object that does not exist. |
| 382 */ | 382 */ |
| 383 static Future<bool> identical(String path1, String path2) { | 383 static Future<bool> identical(String path1, String path2) { |
| 384 return IOService.dispatch(FILE_IDENTICAL, [path1, path2]).then((response) { | 384 return _IOService.dispatch(_FILE_IDENTICAL, [path1, path2]).then((response)
{ |
| 385 if (_isErrorResponse(response)) { | 385 if (_isErrorResponse(response)) { |
| 386 throw _exceptionFromResponse(response, | 386 throw _exceptionFromResponse(response, |
| 387 "Error in FileSystemEntity.identical($path1, $path2)", ""); | 387 "Error in FileSystemEntity.identical($path1, $path2)", ""); |
| 388 } | 388 } |
| 389 return response; | 389 return response; |
| 390 }); | 390 }); |
| 391 } | 391 } |
| 392 | 392 |
| 393 static final RegExp _absoluteWindowsPathPattern = | 393 static final RegExp _absoluteWindowsPathPattern = |
| 394 new RegExp(r'^(\\\\|[a-zA-Z]:[/\\])'); | 394 new RegExp(r'^(\\\\|[a-zA-Z]:[/\\])'); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 external static _identical(String path1, String path2); | 530 external static _identical(String path1, String path2); |
| 531 external static _resolveSymbolicLinks(String path); | 531 external static _resolveSymbolicLinks(String path); |
| 532 | 532 |
| 533 static int _getTypeSync(String path, bool followLinks) { | 533 static int _getTypeSync(String path, bool followLinks) { |
| 534 var result = _getType(path, followLinks); | 534 var result = _getType(path, followLinks); |
| 535 _throwIfError(result, 'Error getting type of FileSystemEntity'); | 535 _throwIfError(result, 'Error getting type of FileSystemEntity'); |
| 536 return result; | 536 return result; |
| 537 } | 537 } |
| 538 | 538 |
| 539 static Future<int> _getTypeAsync(String path, bool followLinks) { | 539 static Future<int> _getTypeAsync(String path, bool followLinks) { |
| 540 return IOService.dispatch(FILE_TYPE, [path, followLinks]).then((response) { | 540 return _IOService.dispatch(_FILE_TYPE, [path, followLinks]).then((response)
{ |
| 541 if (_isErrorResponse(response)) { | 541 if (_isErrorResponse(response)) { |
| 542 throw _exceptionFromResponse(response, "Error getting type", path); | 542 throw _exceptionFromResponse(response, "Error getting type", path); |
| 543 } | 543 } |
| 544 return response; | 544 return response; |
| 545 }); | 545 }); |
| 546 } | 546 } |
| 547 | 547 |
| 548 static _throwIfError(Object result, String msg, [String path]) { | 548 static _throwIfError(Object result, String msg, [String path]) { |
| 549 if (result is OSError) { | 549 if (result is OSError) { |
| 550 throw new FileException(msg, path, result); | 550 throw new FileException(msg, path, result); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 | 663 |
| 664 | 664 |
| 665 abstract class _FileSystemWatcher { | 665 abstract class _FileSystemWatcher { |
| 666 external factory _FileSystemWatcher(String path, int events, bool recursive); | 666 external factory _FileSystemWatcher(String path, int events, bool recursive); |
| 667 external static bool get isSupported; | 667 external static bool get isSupported; |
| 668 | 668 |
| 669 Stream<FileSystemEvent> get stream; | 669 Stream<FileSystemEvent> get stream; |
| 670 } | 670 } |
| OLD | NEW |