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

Side by Side Diff: runtime/bin/directory_win.cc

Issue 25720002: Add Directory.systemTemp getter to replace createSystemTemp(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't add an extra / to a directory ending in // Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/directory_patch.dart ('k') | runtime/bin/io_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/file.h" 9 #include "bin/file.h"
10 #include "bin/utils.h" 10 #include "bin/utils.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 GetLastError() == ERROR_ALREADY_EXISTS && 376 GetLastError() == ERROR_ALREADY_EXISTS &&
377 ExistsHelper(system_name) == EXISTS) { 377 ExistsHelper(system_name) == EXISTS) {
378 free(const_cast<wchar_t*>(system_name)); 378 free(const_cast<wchar_t*>(system_name));
379 return true; 379 return true;
380 } 380 }
381 free(const_cast<wchar_t*>(system_name)); 381 free(const_cast<wchar_t*>(system_name));
382 return (create_status != 0); 382 return (create_status != 0);
383 } 383 }
384 384
385 385
386 char* Directory::CreateTemp(const char* const_template, bool system) { 386 char* Directory::SystemTemp() {
387 // Returns a new, unused directory name, modifying the contents of 387 PathBuffer path;
388 // dir_template. Creates this directory, with a default security 388 path.Reset(GetTempPathW(MAX_PATH, path.AsStringW()) - 1); // Remove \ at end.
389 return path.AsString();
390 }
391
392
393 char* Directory::CreateTemp(const char* prefix) {
394 // Returns a new, unused directory name, adding characters to the
395 // end of prefix.
396 // Creates this directory, with a default security
389 // descriptor inherited from its parent directory. 397 // descriptor inherited from its parent directory.
390 // The return value must be freed by the caller. 398 // The return value must be freed by the caller.
391 PathBuffer path; 399 PathBuffer path;
392 if (system) { 400 const wchar_t* system_prefix = StringUtils::Utf8ToWide(prefix);
393 path.Reset(GetTempPathW(MAX_PATH, path.AsStringW())); 401 path.AddW(system_prefix);
394 if (path.length() == 0) { 402 free(const_cast<wchar_t*>(system_prefix));
395 return NULL;
396 }
397 }
398 const wchar_t* system_template = StringUtils::Utf8ToWide(const_template);
399 path.AddW(system_template);
400 free(const_cast<wchar_t*>(system_template));
401 403
402 // Length of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36. 404 // Length of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx is 36.
403 if (path.length() > MAX_PATH - 36) { 405 if (path.length() > MAX_PATH - 36) {
404 return NULL; 406 return NULL;
405 } 407 }
406 408
407 UUID uuid; 409 UUID uuid;
408 RPC_STATUS status = UuidCreateSequential(&uuid); 410 RPC_STATUS status = UuidCreateSequential(&uuid);
409 if (status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY) { 411 if (status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY) {
410 return NULL; 412 return NULL;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 MoveFileExW(system_path, system_new_path, flags); 466 MoveFileExW(system_path, system_new_path, flags);
465 free(const_cast<wchar_t*>(system_path)); 467 free(const_cast<wchar_t*>(system_path));
466 free(const_cast<wchar_t*>(system_new_path)); 468 free(const_cast<wchar_t*>(system_new_path));
467 return (move_status != 0); 469 return (move_status != 0);
468 } 470 }
469 471
470 } // namespace bin 472 } // namespace bin
471 } // namespace dart 473 } // namespace dart
472 474
473 #endif // defined(TARGET_OS_WINDOWS) 475 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« 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