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

Unified Diff: runtime/bin/file.cc

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 | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index ae417e74891f7fb6a6b94d444cc59a121cebe742..5c54ed8579360eef0dc579d8ea9525e3c5aa0c1c 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -555,8 +555,34 @@ void FUNCTION_NAME(File_GetType)(Dart_NativeArguments args) {
File::Type type = File::GetType(str, follow_links);
Dart_SetReturnValue(args, Dart_NewInteger(static_cast<int>(type)));
} else {
- OSError os_error(-1, "Invalid argument", OSError::kUnknown);
- Dart_Handle err = DartUtils::NewDartOSError(&os_error);
+ Dart_Handle err = DartUtils::NewDartArgumentError(
+ "Non-string argument to FileSystemEntity.type");
+ if (Dart_IsError(err)) Dart_PropagateError(err);
+ Dart_SetReturnValue(args, err);
+ }
+ Dart_ExitScope();
+}
+
+
+void FUNCTION_NAME(File_AreIdentical)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ if (Dart_IsString(Dart_GetNativeArgument(args, 0)) &&
+ Dart_IsString(Dart_GetNativeArgument(args, 1))) {
+ const char* path_1 =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
+ const char* path_2 =
+ DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
+ File::Identical result = File::AreIdentical(path_1, path_2);
+ if (result == File::kError) {
+ Dart_Handle err = DartUtils::NewDartOSError();
+ if (Dart_IsError(err)) Dart_PropagateError(err);
+ Dart_SetReturnValue(args, err);
+ } else {
+ Dart_SetReturnValue(args, Dart_NewBoolean(result == File::kIdentical));
+ }
+ } else {
+ Dart_Handle err = DartUtils::NewDartArgumentError(
+ "Non-string argument to FileSystemEntity.identical");
if (Dart_IsError(err)) Dart_PropagateError(err);
Dart_SetReturnValue(args, err);
}
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698