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

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: Update status file and fix checked mode 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
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));
Søren Gjesse 2013/05/03 07:13:36 This still needs to be calling a service finction
Bill Hesse 2013/05/03 08:44:06 This is done in a follow-up CL, already written.
+
+ /**
+ * 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>(
Bill Hesse 2013/05/02 14:02:42 This function could be changed to its final, corre
Bill Hesse 2013/05/03 08:44:06 Done in the second CL.
+ () => 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);

Powered by Google App Engine
This is Rietveld 408576698