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

Unified Diff: runtime/bin/directory_win.cc

Issue 25279003: dart:io | Add Directory.CreateSystemTemp(template) and change Directory.CreateTemp(template). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add check of "TMP" environment variable if "TMPDIR" is missing. Created 7 years, 3 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_patch.dart ('k') | runtime/bin/io_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_win.cc
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index f5f77bd99dc568fb51a6b9087763e7c0217b8345..c72f4ef8f0cd0c9a1092f9577464adc3945969ca 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -383,30 +383,26 @@ bool Directory::Create(const char* dir_name) {
}
-char* Directory::CreateTemp(const char* const_template) {
+char* Directory::CreateTemp(const char* const_template, bool system) {
// Returns a new, unused directory name, modifying the contents of
// dir_template. Creates this directory, with a default security
// descriptor inherited from its parent directory.
// The return value must be freed by the caller.
PathBuffer path;
- if (0 == strncmp(const_template, "", 1)) {
+ if (system) {
path.Reset(GetTempPathW(MAX_PATH, path.AsStringW()));
if (path.length() == 0) {
return NULL;
}
- } else {
- const wchar_t* system_template = StringUtils::Utf8ToWide(const_template);
- path.AddW(system_template);
- free(const_cast<wchar_t*>(system_template));
}
- // Length of tempdir-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 44.
- if (path.length() > MAX_PATH - 44) {
+ const wchar_t* system_template = StringUtils::Utf8ToWide(const_template);
+ path.AddW(system_template);
+ free(const_cast<wchar_t*>(system_template));
+
+ // Length of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36.
+ if (path.length() > MAX_PATH - 36) {
return NULL;
}
- if ((path.AsStringW())[path.length() - 1] == L'\\') {
- // No base name for the directory - use "tempdir".
- path.AddW(L"tempdir");
- }
UUID uuid;
RPC_STATUS status = UuidCreateSequential(&uuid);
@@ -419,7 +415,6 @@ char* Directory::CreateTemp(const char* const_template) {
return NULL;
}
- path.AddW(L"-");
// RPC_WSTR is an unsigned short*, so we cast to wchar_t*.
path.AddW(reinterpret_cast<wchar_t*>(uuid_string));
RpcStringFreeW(&uuid_string);
« no previous file with comments | « runtime/bin/directory_patch.dart ('k') | runtime/bin/io_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698