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

Unified Diff: sdk/lib/io/file_system_entity.dart

Issue 14642012: dart:io | Add asynchronous versions of the methods of FileSystemEntity and Link. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/link.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0649d18e474470e4cdbb7516754f815280067c66 100644
--- a/sdk/lib/io/file_system_entity.dart
+++ b/sdk/lib/io/file_system_entity.dart
@@ -43,6 +43,22 @@ abstract class FileSystemEntity {
return result;
}
+ static Future<int> _getTypeAsync(String path, bool followLinks) =>
+ new Future(() => _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) =>
+ new Future<bool>(() => identicalSync(path1, path2));
+
/**
* Do two paths refer to the same object in the file system?
* Links are not identical to their targets, and two links
@@ -59,9 +75,23 @@ abstract class FileSystemEntity {
return result;
}
+ static Future<FileSystemEntityType> type(String path,
+ {bool followLinks: true})
+ => new Future<FileSystemEntityType>(
+ () => 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);
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | sdk/lib/io/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698