OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ |
6 #define CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ | 6 #define CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <windows.h> | 9 #include <windows.h> |
10 | |
11 #include "base/file_path.h" | |
12 #include "chrome/installer/util/work_item.h" | 10 #include "chrome/installer/util/work_item.h" |
13 | 11 |
14 // A WorkItem subclass that recursively copies a file system hierarchy from | 12 // A WorkItem subclass that recursively copies a file system hierarchy from |
15 // source path to destination path. It also creates all necessary intermediate | 13 // source path to destination path. It also creates all necessary intermediate |
16 // paths of the destination path if they do not exist. The file system | 14 // paths of the destination path if they do not exist. The file system |
17 // hierarchy could be a single file, or a directory. | 15 // hierarchy could be a single file, or a directory. |
18 // Under the cover CopyTreeWorkItem moves the destination path, if existing, | 16 // Under the cover CopyTreeWorkItem moves the destination path, if existing, |
19 // to the temporary directory passed in, and then copies the source hierarchy | 17 // to the temporary directory passed in, and then copies the source hierarchy |
20 // to the destination location. During rollback the original destination | 18 // to the destination location. During rollback the original destination |
21 // hierarchy is moved back. | 19 // hierarchy is moved back. |
(...skipping 13 matching lines...) Expand all Loading... |
35 // Notes on temp_path: to facilitate rollback, the caller needs to supply | 33 // Notes on temp_path: to facilitate rollback, the caller needs to supply |
36 // a temporary directory to save the original files if they exist under | 34 // a temporary directory to save the original files if they exist under |
37 // dest_path. | 35 // dest_path. |
38 CopyTreeWorkItem(const std::wstring& source_path, | 36 CopyTreeWorkItem(const std::wstring& source_path, |
39 const std::wstring& dest_path, | 37 const std::wstring& dest_path, |
40 const std::wstring& temp_dir, | 38 const std::wstring& temp_dir, |
41 CopyOverWriteOption overwrite_option, | 39 CopyOverWriteOption overwrite_option, |
42 const std::wstring& alternative_path); | 40 const std::wstring& alternative_path); |
43 | 41 |
44 // Checks if the path specified is in use (and hence can not be deleted) | 42 // Checks if the path specified is in use (and hence can not be deleted) |
45 bool IsFileInUse(const FilePath& path); | 43 bool IsFileInUse(const std::wstring& path); |
46 | 44 |
47 // Get a backup path that can keep the original files under dest_path_, | 45 // Get a backup path that can keep the original files under dest_path_, |
48 // and set backup_path_ with the result. | 46 // and set backup_path_ with the result. |
49 bool GetBackupPath(); | 47 bool GetBackupPath(); |
50 | 48 |
51 // Source path to copy files from. | 49 // Source path to copy files from. |
52 FilePath source_path_; | 50 std::wstring source_path_; |
53 | 51 |
54 // Destination path to copy files to. | 52 // Destination path to copy files to. |
55 FilePath dest_path_; | 53 std::wstring dest_path_; |
56 | 54 |
57 // Temporary directory that can be used. | 55 // Temporary directory that can be used. |
58 FilePath temp_dir_; | 56 std::wstring temp_dir_; |
59 | 57 |
60 // Controls the behavior for overwriting. | 58 // Controls the behavior for overwriting. |
61 CopyOverWriteOption overwrite_option_; | 59 CopyOverWriteOption overwrite_option_; |
62 | 60 |
63 // If overwrite_option_ = NEW_NAME_IF_IN_USE, this variables stores the path | 61 // If overwrite_option_ = NEW_NAME_IF_IN_USE, this variables stores the path |
64 // to be used if the file is in use and hence we want to copy it to a | 62 // to be used if the file is in use and hence we want to copy it to a |
65 // different path. | 63 // different path. |
66 FilePath alternative_path_; | 64 std::wstring alternative_path_; |
67 | 65 |
68 // Whether the source was copied to dest_path_ | 66 // Whether the source was copied to dest_path_ |
69 bool copied_to_dest_path_; | 67 bool copied_to_dest_path_; |
70 | 68 |
71 // Whether the original files have been moved to backup path under | 69 // Whether the original files have been moved to backup path under |
72 // temporary directory. If true, moving back is needed during rollback. | 70 // temporary directory. If true, moving back is needed during rollback. |
73 bool moved_to_backup_; | 71 bool moved_to_backup_; |
74 | 72 |
75 // Whether the source was copied to alternative_path_ because dest_path_ | 73 // Whether the source was copied to alternative_path_ because dest_path_ |
76 // existed and was in use. Needed during rollback. | 74 // existed and was in use. Needed during rollback. |
77 bool copied_to_alternate_path_; | 75 bool copied_to_alternate_path_; |
78 | 76 |
79 // The full path in temporary directory that the original dest_path_ has | 77 // The full path in temporary directory that the original dest_path_ has |
80 // been moved to. | 78 // been moved to. |
81 FilePath backup_path_; | 79 std::wstring backup_path_; |
82 }; | 80 }; |
83 | 81 |
84 #endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ | 82 #endif // CHROME_INSTALLER_UTIL_COPY_TREE_WORK_ITEM_H_ |
OLD | NEW |