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

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: Fix Windows build. 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
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory.cc
diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc
index d600f3df935d5fba08910b18008eceb2797c7328..5cb4296a395e510bd1da6038dbbd8466dcf23b74 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,41 @@ 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));
+ Directory::ExistsResult result =
+ Directory::Exists(DartUtils::GetStringValue(path));
+ int return_value = -1;
+ if (result == Directory::EXISTS) {
+ return_value = 1;
+ }
+ if (result == Directory::DOES_NOT_EXIST) {
+ return_value = 0;
+ }
+ 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();
+}
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698