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

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

Issue 12850010: Add FileSystemEntity.identical, to test if two file system objects are the same. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change argument names from file1, file2 to path1, path2. Created 7 years, 9 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/_internal/compiler/implementation/lib/io_patch.dart ('k') | tests/standalone/io/link_test.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 e13477b1c41e5b6c11e732e01977ccaa47d985b9..ac00741528f7b254f64b89412d05a4baf94bd990 100644
--- a/sdk/lib/io/file_system_entity.dart
+++ b/sdk/lib/io/file_system_entity.dart
@@ -35,6 +35,7 @@ abstract class FileSystemEntity {
String get path;
external static int _getType(String path, bool followLinks);
+ external static bool _identical(String path1, String path2);
static int _getTypeSync(String path, bool followLinks) {
var result = _getType(path, followLinks);
@@ -42,6 +43,22 @@ abstract class FileSystemEntity {
return result;
}
+ /**
+ * 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 bool identicalSync(String path1, String path2) {
+ var result = _identical(path1, path2);
+ _throwIfError(result, 'Error in FileSystemEntity.identical');
+ return result;
+ }
+
static FileSystemEntityType typeSync(String path, {bool followLinks: true})
=> FileSystemEntityType._lookup(_getTypeSync(path, followLinks));
@@ -57,6 +74,8 @@ abstract class FileSystemEntity {
static _throwIfError(Object result, String msg) {
if (result is OSError) {
throw new FileIOException(msg, result);
+ } else if (result is ArgumentError) {
+ throw result;
}
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/io_patch.dart ('k') | tests/standalone/io/link_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698