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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 /** | 218 /** |
219 * Resolves the path of a file system object relative to the | 219 * Resolves the path of a file system object relative to the |
220 * current working directory, resolving all symbolic links on | 220 * current working directory, resolving all symbolic links on |
221 * the path and resolving all '..' and '.' path segments. | 221 * the path and resolving all '..' and '.' path segments. |
222 * [resolveSymbolicLinks] returns a [:Future<String>:] | 222 * [resolveSymbolicLinks] returns a [:Future<String>:] |
223 * | 223 * |
224 * [resolveSymbolicLinks] uses the operating system's native filesystem api | 224 * [resolveSymbolicLinks] uses the operating system's native filesystem api |
225 * to resolve the path, using the realpath function on linux and | 225 * to resolve the path, using the realpath function on linux and |
226 * Mac OS, and the GetFinalPathNameByHandle function on Windows. | 226 * Mac OS, and the GetFinalPathNameByHandle function on Windows. |
227 * If the path does not point to an existing file system object, | 227 * If the path does not point to an existing file system object, |
228 * [resolveSymbolicLinks] completes the returned Future with an FileException. | 228 * [resolveSymbolicLinks] completes the returned Future with an FileSystemExce
ption. |
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() { |
(...skipping 10 matching lines...) Expand all Loading... |
249 | 249 |
250 /** | 250 /** |
251 * Resolves the path of a file system object relative to the | 251 * Resolves the path of a file system object relative to the |
252 * current working directory, resolving all symbolic links on | 252 * current working directory, resolving all symbolic links on |
253 * the path and resolving all '..' and '.' path segments. | 253 * the path and resolving all '..' and '.' path segments. |
254 * | 254 * |
255 * [resolveSymbolicLinksSync] uses the operating system's native | 255 * [resolveSymbolicLinksSync] uses the operating system's native |
256 * filesystem api to resolve the path, using the realpath function | 256 * filesystem api to resolve the path, using the realpath function |
257 * on linux and Mac OS, and the GetFinalPathNameByHandle function on Windows. | 257 * on linux and Mac OS, and the GetFinalPathNameByHandle function on Windows. |
258 * If the path does not point to an existing file system object, | 258 * If the path does not point to an existing file system object, |
259 * [resolveSymbolicLinksSync] throws a FileException. | 259 * [resolveSymbolicLinksSync] throws a FileSystemException. |
260 * | 260 * |
261 * On Windows, symbolic links are resolved to their target before applying | 261 * On Windows, symbolic links are resolved to their target before applying |
262 * a '..' that follows, and on other platforms, the '..' is applied to the | 262 * a '..' that follows, and on other platforms, the '..' is applied to the |
263 * symbolic link without resolving it. The second behavior can be emulated | 263 * symbolic link without resolving it. The second behavior can be emulated |
264 * on Windows by processing any '..' segments before calling | 264 * on Windows by processing any '..' segments before calling |
265 * [resolveSymbolicLinks]. One way of doing this is with the URI class: | 265 * [resolveSymbolicLinks]. One way of doing this is with the URI class: |
266 * [:new Uri.parse('.').resolveUri(new Uri.file(input)).toFilePath();], | 266 * [:new Uri.parse('.').resolveUri(new Uri.file(input)).toFilePath();], |
267 * since [resolve] removes '..' segments. | 267 * since [resolve] removes '..' segments. |
268 */ | 268 */ |
269 String resolveSymbolicLinksSync() { | 269 String resolveSymbolicLinksSync() { |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 .then((response) { | 585 .then((response) { |
586 if (_isErrorResponse(response)) { | 586 if (_isErrorResponse(response)) { |
587 throw _exceptionFromResponse(response, "Error getting type", path); | 587 throw _exceptionFromResponse(response, "Error getting type", path); |
588 } | 588 } |
589 return response; | 589 return response; |
590 }); | 590 }); |
591 } | 591 } |
592 | 592 |
593 static _throwIfError(Object result, String msg, [String path]) { | 593 static _throwIfError(Object result, String msg, [String path]) { |
594 if (result is OSError) { | 594 if (result is OSError) { |
595 throw new FileException(msg, path, result); | 595 throw new FileSystemException(msg, path, result); |
596 } else if (result is ArgumentError) { | 596 } else if (result is ArgumentError) { |
597 throw result; | 597 throw result; |
598 } | 598 } |
599 } | 599 } |
600 | 600 |
601 static String _trimTrailingPathSeparators(String path) { | 601 static String _trimTrailingPathSeparators(String path) { |
602 // Don't handle argument errors here. | 602 // Don't handle argument errors here. |
603 if (path is! String) return path; | 603 if (path is! String) return path; |
604 if (Platform.operatingSystem == 'windows') { | 604 if (Platform.operatingSystem == 'windows') { |
605 while (path.length > 1 && | 605 while (path.length > 1 && |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 } | 707 } |
708 } | 708 } |
709 | 709 |
710 | 710 |
711 abstract class _FileSystemWatcher { | 711 abstract class _FileSystemWatcher { |
712 external factory _FileSystemWatcher(String path, int events, bool recursive); | 712 external factory _FileSystemWatcher(String path, int events, bool recursive); |
713 external static bool get isSupported; | 713 external static bool get isSupported; |
714 | 714 |
715 Stream<FileSystemEvent> get stream; | 715 Stream<FileSystemEvent> get stream; |
716 } | 716 } |
OLD | NEW |