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

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 deadline for removing compatibility mode. 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
Index: runtime/bin/directory_win.cc
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index f5f77bd99dc568fb51a6b9087763e7c0217b8345..1995972eff951d79df8d9ad24bfdccdc1c351463 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 37.
+ if (path.length() > MAX_PATH - 37) {
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);

Powered by Google App Engine
This is Rietveld 408576698