OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <psapi.h> | 8 #include <psapi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 // Since we're passing flags to the operation telling it to be silent, | 88 // Since we're passing flags to the operation telling it to be silent, |
89 // it's possible for the operation to be aborted/cancelled without err | 89 // it's possible for the operation to be aborted/cancelled without err |
90 // being set (although MSDN doesn't give any scenarios for how this can | 90 // being set (although MSDN doesn't give any scenarios for how this can |
91 // happen). See MSDN for SHFileOperation and SHFILEOPTSTRUCT. | 91 // happen). See MSDN for SHFileOperation and SHFILEOPTSTRUCT. |
92 if (file_operation.fAnyOperationsAborted) | 92 if (file_operation.fAnyOperationsAborted) |
93 return false; | 93 return false; |
94 | 94 |
95 // Some versions of Windows return ERROR_FILE_NOT_FOUND (0x2) when deleting | 95 // Some versions of Windows return ERROR_FILE_NOT_FOUND (0x2) when deleting |
96 // an empty directory and some return 0x402 when they should be returning | 96 // an empty directory and some return 0x402 when they should be returning |
97 // ERROR_FILE_NOT_FOUND. MSDN says Vista and up won't return 0x402. | 97 // ERROR_FILE_NOT_FOUND. MSDN says Vista and up won't return 0x402. Windows 7 |
98 return (err == 0 || err == ERROR_FILE_NOT_FOUND || err == 0x402); | 98 // can return DE_INVALIDFILES (0x7C) for nonexistent directories. |
| 99 return (err == 0 || err == ERROR_FILE_NOT_FOUND || err == 0x402 || |
| 100 err == 0x7C); |
99 } | 101 } |
100 | 102 |
101 bool DeleteFileAfterReboot(const FilePath& path) { | 103 bool DeleteFileAfterReboot(const FilePath& path) { |
102 ThreadRestrictions::AssertIOAllowed(); | 104 ThreadRestrictions::AssertIOAllowed(); |
103 | 105 |
104 if (path.value().length() >= MAX_PATH) | 106 if (path.value().length() >= MAX_PATH) |
105 return false; | 107 return false; |
106 | 108 |
107 return MoveFileEx(path.value().c_str(), NULL, | 109 return MoveFileEx(path.value().c_str(), NULL, |
108 MOVEFILE_DELAY_UNTIL_REBOOT | | 110 MOVEFILE_DELAY_UNTIL_REBOOT | |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // Like Move, this function is not transactional, so we just | 787 // Like Move, this function is not transactional, so we just |
786 // leave the copied bits behind if deleting from_path fails. | 788 // leave the copied bits behind if deleting from_path fails. |
787 // If to_path exists previously then we have already overwritten | 789 // If to_path exists previously then we have already overwritten |
788 // it by now, we don't get better off by deleting the new bits. | 790 // it by now, we don't get better off by deleting the new bits. |
789 } | 791 } |
790 return false; | 792 return false; |
791 } | 793 } |
792 | 794 |
793 } // namespace internal | 795 } // namespace internal |
794 } // namespace base | 796 } // namespace base |
OLD | NEW |