| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <propvarutil.h> | 8 #include <propvarutil.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 file_operation.pFrom = double_terminated_path; | 91 file_operation.pFrom = double_terminated_path; |
| 92 file_operation.fFlags = FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION; | 92 file_operation.fFlags = FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION; |
| 93 if (!recursive) | 93 if (!recursive) |
| 94 file_operation.fFlags |= FOF_NORECURSION | FOF_FILESONLY; | 94 file_operation.fFlags |= FOF_NORECURSION | FOF_FILESONLY; |
| 95 int err = SHFileOperation(&file_operation); | 95 int err = SHFileOperation(&file_operation); |
| 96 // Some versions of Windows return ERROR_FILE_NOT_FOUND when | 96 // Some versions of Windows return ERROR_FILE_NOT_FOUND when |
| 97 // deleting an empty directory. | 97 // deleting an empty directory. |
| 98 return (err == 0 || err == ERROR_FILE_NOT_FOUND); | 98 return (err == 0 || err == ERROR_FILE_NOT_FOUND); |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool DeleteAfterReboot(const FilePath& path) { |
| 102 if (path.value().length() >= MAX_PATH) |
| 103 return false; |
| 104 |
| 105 return MoveFileEx(path.value().c_str(), NULL, |
| 106 MOVEFILE_DELAY_UNTIL_REBOOT | |
| 107 MOVEFILE_REPLACE_EXISTING) != FALSE; |
| 108 } |
| 109 |
| 101 bool Move(const FilePath& from_path, const FilePath& to_path) { | 110 bool Move(const FilePath& from_path, const FilePath& to_path) { |
| 102 // NOTE: I suspect we could support longer paths, but that would involve | 111 // NOTE: I suspect we could support longer paths, but that would involve |
| 103 // analyzing all our usage of files. | 112 // analyzing all our usage of files. |
| 104 if (from_path.value().length() >= MAX_PATH || | 113 if (from_path.value().length() >= MAX_PATH || |
| 105 to_path.value().length() >= MAX_PATH) { | 114 to_path.value().length() >= MAX_PATH) { |
| 106 return false; | 115 return false; |
| 107 } | 116 } |
| 108 if (MoveFileEx(from_path.value().c_str(), to_path.value().c_str(), | 117 if (MoveFileEx(from_path.value().c_str(), to_path.value().c_str(), |
| 109 MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING) != 0) | 118 MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING) != 0) |
| 110 return true; | 119 return true; |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 848 } |
| 840 | 849 |
| 841 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, | 850 bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, |
| 842 const base::Time& cutoff_time) { | 851 const base::Time& cutoff_time) { |
| 843 long result = CompareFileTime(&find_info.ftLastWriteTime, | 852 long result = CompareFileTime(&find_info.ftLastWriteTime, |
| 844 &cutoff_time.ToFileTime()); | 853 &cutoff_time.ToFileTime()); |
| 845 return result == 1 || result == 0; | 854 return result == 1 || result == 0; |
| 846 } | 855 } |
| 847 | 856 |
| 848 } // namespace file_util | 857 } // namespace file_util |
| OLD | NEW |