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

Unified Diff: runtime/bin/directory.cc

Issue 8277033: Add exists, create and delete to directory implementation on Linux and Mac. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 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: runtime/bin/directory.cc
diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc
index d600f3df935d5fba08910b18008eceb2797c7328..6988b0ac212c4814c6e447ec73a638d5dcdd5a56 100644
--- a/runtime/bin/directory.cc
+++ b/runtime/bin/directory.cc
@@ -9,7 +9,6 @@
static intptr_t GetHandlerPort(Dart_Handle handle) {
if (Dart_IsNull(handle)) {
- // TODO(ager): Generalize this to Directory::kInvalidId.
return 0;
}
return DartUtils::GetIntegerInstanceField(handle, DartUtils::kIdFieldName);
@@ -34,3 +33,35 @@ void FUNCTION_NAME(Directory_List)(Dart_NativeArguments args) {
error_port);
Dart_ExitScope();
}
+
+
+void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_Handle path = Dart_GetNativeArgument(args, 1);
+ ASSERT(Dart_IsString(path));
+ bool exists = false;
+ bool success = Directory::Exists(DartUtils::GetStringValue(path), &exists);
Søren Gjesse 2011/10/14 11:44:14 How about returning an enum Yes/No/Don't know inst
Mads Ager (google) 2011/10/14 12:22:54 Done.
+ int return_value = success ? (exists ? 1 : 0) : -1;
+ Dart_SetReturnValue(args, Dart_NewInteger(return_value));
+ Dart_ExitScope();
+}
+
+
+void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_Handle path = Dart_GetNativeArgument(args, 1);
+ ASSERT(Dart_IsString(path));
+ bool created = Directory::Create(DartUtils::GetStringValue(path));
+ Dart_SetReturnValue(args, Dart_NewBoolean(created));
+ Dart_ExitScope();
+}
+
+
+void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) {
+ Dart_EnterScope();
+ Dart_Handle path = Dart_GetNativeArgument(args, 1);
+ ASSERT(Dart_IsString(path));
+ bool deleted = Directory::Delete(DartUtils::GetStringValue(path));
+ Dart_SetReturnValue(args, Dart_NewBoolean(deleted));
+ Dart_ExitScope();
+}

Powered by Google App Engine
This is Rietveld 408576698