Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "bin/directory.h" | 5 #include "bin/directory.h" |
| 6 | |
|
Ivan Posva
2012/11/17 01:13:42
Please leave the empty line.
gram
2012/11/19 17:38:56
Done.
| |
| 7 #include <errno.h> | 6 #include <errno.h> |
| 8 #include <sys/stat.h> | 7 #include <sys/stat.h> |
| 9 | 8 |
| 10 #include "bin/platform.h" | 9 #include "bin/log.h" |
| 11 | |
| 12 | 10 |
| 13 static int SetOsErrorMessage(char* os_error_message, | 11 static int SetOsErrorMessage(char* os_error_message, |
| 14 int os_error_message_len) { | 12 int os_error_message_len) { |
| 15 int error_code = GetLastError(); | 13 int error_code = GetLastError(); |
| 16 DWORD message_size = | 14 DWORD message_size = |
| 17 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | 15 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 18 NULL, | 16 NULL, |
| 19 error_code, | 17 error_code, |
| 20 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | 18 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
| 21 os_error_message, | 19 os_error_message, |
| 22 os_error_message_len, | 20 os_error_message_len, |
| 23 NULL); | 21 NULL); |
| 24 if (message_size == 0) { | 22 if (message_size == 0) { |
| 25 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { | 23 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { |
| 26 fprintf(stderr, "FormatMessage failed %d\n", GetLastError()); | 24 Log::PrintErr("FormatMessage failed %d\n", GetLastError()); |
| 27 } | 25 } |
| 28 snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code); | 26 snprintf(os_error_message, os_error_message_len, "OS Error %d", error_code); |
| 29 } | 27 } |
| 30 os_error_message[os_error_message_len - 1] = '\0'; | 28 os_error_message[os_error_message_len - 1] = '\0'; |
| 31 return error_code; | 29 return error_code; |
| 32 } | 30 } |
| 33 | 31 |
| 34 | 32 |
| 35 // Forward declaration. | 33 // Forward declaration. |
| 36 static bool ListRecursively(const char* dir_name, | 34 static bool ListRecursively(const char* dir_name, |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 bool success = DeleteRecursively(system_new_path); | 460 bool success = DeleteRecursively(system_new_path); |
| 463 if (!success) return false; | 461 if (!success) return false; |
| 464 } | 462 } |
| 465 DWORD flags = MOVEFILE_WRITE_THROUGH; | 463 DWORD flags = MOVEFILE_WRITE_THROUGH; |
| 466 int move_status = | 464 int move_status = |
| 467 MoveFileEx(system_path, system_new_path, flags); | 465 MoveFileEx(system_path, system_new_path, flags); |
| 468 free(const_cast<char*>(system_path)); | 466 free(const_cast<char*>(system_path)); |
| 469 free(const_cast<char*>(system_new_path)); | 467 free(const_cast<char*>(system_new_path)); |
| 470 return (move_status != 0); | 468 return (move_status != 0); |
| 471 } | 469 } |
| OLD | NEW |