Index: sdk/lib/io/file_system_entity.dart |
diff --git a/sdk/lib/io/file_system_entity.dart b/sdk/lib/io/file_system_entity.dart |
index ac00741528f7b254f64b89412d05a4baf94bd990..f3f8955158666fa11e5ef9e0ffa53e9cc6ef3141 100644 |
--- a/sdk/lib/io/file_system_entity.dart |
+++ b/sdk/lib/io/file_system_entity.dart |
@@ -43,6 +43,25 @@ abstract class FileSystemEntity { |
return result; |
} |
+ static Future<int> _getTypeAsync(String path, bool followLinks) => |
+ new Future.sync(() => _getTypeSync(path, followLinks)); |
+ |
+ /** |
+ * Do two paths refer to the same object in the file system? |
+ * Links are not identical to their targets, and two links |
+ * are not identical just because they point to identical targets. |
+ * Links in intermediate directories in the paths are followed, though. |
+ * |
+ * Throws an error if one of the paths points to an object that does not |
+ * exist. |
+ * The target of a link can be compared by first getting it with Link.target. |
+ */ |
+ static Future<bool> identical(String path1, String path2) { |
+ var result = _identical(path1, path2); |
+ _throwIfError(result, 'Error in FileSystemEntity.identical'); |
Bill Hesse
2013/05/02 14:02:42
Error should be on the future.
Bill Hesse
2013/05/02 14:02:42
Fixed - all errors are now on the Futures.
|
+ return new Future<bool>.value(result); |
+ } |
+ |
/** |
* Do two paths refer to the same object in the file system? |
* Links are not identical to their targets, and two links |
@@ -59,9 +78,23 @@ abstract class FileSystemEntity { |
return result; |
} |
+ static Future<FileSystemEntityType> type(String path, |
+ {bool followLinks: true}) |
+ => new Future<FileSystemEntityType>.value( |
+ typeSync(path, followLinks: followLinks)); |
+ |
static FileSystemEntityType typeSync(String path, {bool followLinks: true}) |
=> FileSystemEntityType._lookup(_getTypeSync(path, followLinks)); |
+ static Future<bool> isLink(String path) => _getTypeAsync(path, false).then( |
+ (type) => (type == FileSystemEntityType.LINK._type)); |
+ |
+ static Future<bool> isFile(String path) => _getTypeAsync(path, true).then( |
+ (type) => (type == FileSystemEntityType.FILE._type)); |
+ |
+ static Future<bool> isDirectory(String path) => _getTypeAsync(path, true) |
+ .then((type) => (type == FileSystemEntityType.DIRECTORY._type)); |
+ |
static bool isLinkSync(String path) => |
(_getTypeSync(path, false) == FileSystemEntityType.LINK._type); |