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

Unified Diff: runtime/bin/directory_posix.cc

Issue 8588029: Add Directory.createTemp() to asynchronously create a temporary directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added Windows code. Created 9 years, 1 month 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_posix.cc
diff --git a/runtime/bin/directory_posix.cc b/runtime/bin/directory_posix.cc
index 21cc054db8bebde6617d05c1ca4704031bc7c722..b83244ea03e0ba08c335a7e9f4f7f6cb1ca33e21 100644
--- a/runtime/bin/directory_posix.cc
+++ b/runtime/bin/directory_posix.cc
@@ -253,6 +253,22 @@ bool Directory::Create(const char* dir_name) {
}
+char* Directory::CreateTemp(const char* const_template) {
+ // Returns a new, unused directory name, modifying the contents of
+ // dir_template. Creates this directory, with mode ???.
Mads Ager (google) 2011/11/18 09:50:45 Update comment with the actual mode.
Bill Hesse 2011/11/21 15:48:41 Done.
+ // The return value must be freed by the caller.
+ char* path = static_cast<char*>(malloc(PATH_MAX + 1));
+ strncpy(path, const_template, PATH_MAX + 1);
+ path[PATH_MAX] = '\0';
+ char* result = mkdtemp(path);
+ if (result == NULL) {
+ // Return the empty string, but as a freeable array.
+ path[0] = '\0';
+ }
+ return path;
+}
+
+
bool Directory::Delete(const char* dir_name) {
return (rmdir(dir_name) == 0);
}

Powered by Google App Engine
This is Rietveld 408576698