Chromium Code Reviews| 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); |
| } |