| 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 <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #include <time.h> | 10 #include <time.h> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 file_operation.fFlags |= FOF_NORECURSION | FOF_FILESONLY; | 168 file_operation.fFlags |= FOF_NORECURSION | FOF_FILESONLY; |
| 169 | 169 |
| 170 return (SHFileOperation(&file_operation) == 0); | 170 return (SHFileOperation(&file_operation) == 0); |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, | 173 bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, |
| 174 bool recursive) { | 174 bool recursive) { |
| 175 if (recursive) | 175 if (recursive) |
| 176 return ShellCopy(from_path, to_path, true); | 176 return ShellCopy(from_path, to_path, true); |
| 177 | 177 |
| 178 // The following code assumes that from path is a directory. |
| 179 DCHECK(DirectoryExists(from_path)); |
| 180 |
| 178 // Instead of creating a new directory, we copy the old one to include the | 181 // Instead of creating a new directory, we copy the old one to include the |
| 179 // security information of the folder as part of the copy. | 182 // security information of the folder as part of the copy. |
| 180 if (!PathExists(to_path)) { | 183 if (!PathExists(to_path)) { |
| 181 // Except that Vista fails to do that, and instead do a recursive copy if | 184 // Except that Vista fails to do that, and instead do a recursive copy if |
| 182 // the target directory doesn't exist. | 185 // the target directory doesn't exist. |
| 183 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) | 186 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) |
| 184 CreateDirectory(to_path); | 187 CreateDirectory(to_path); |
| 185 else | 188 else |
| 186 ShellCopy(from_path, to_path, false); | 189 ShellCopy(from_path, to_path, false); |
| 187 } | 190 } |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 ::CloseHandle(file_mapping_); | 803 ::CloseHandle(file_mapping_); |
| 801 if (file_ != INVALID_HANDLE_VALUE) | 804 if (file_ != INVALID_HANDLE_VALUE) |
| 802 ::CloseHandle(file_); | 805 ::CloseHandle(file_); |
| 803 | 806 |
| 804 data_ = NULL; | 807 data_ = NULL; |
| 805 file_mapping_ = file_ = INVALID_HANDLE_VALUE; | 808 file_mapping_ = file_ = INVALID_HANDLE_VALUE; |
| 806 length_ = INVALID_FILE_SIZE; | 809 length_ = INVALID_FILE_SIZE; |
| 807 } | 810 } |
| 808 | 811 |
| 809 } // namespace file_util | 812 } // namespace file_util |
| OLD | NEW |