Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: chrome/installer/util/move_tree_work_item.h

Issue 39048: Move files instead of copying them. (Closed)
Patch Set: More code review comments. Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_INSTALLER_UTIL_MOVE_TREE_WORK_ITEM_H_
6 #define CHROME_INSTALLER_UTIL_MOVE_TREE_WORK_ITEM_H_
7
8 #include <string>
9 #include <windows.h>
10
11 #include "chrome/installer/util/work_item.h"
12
13 // A WorkItem subclass that recursively move a file system hierarchy from
14 // source path to destination path. The file system hierarchy could be a
15 // single file, or a directory.
16 //
17 // Under the cover MoveTreeWorkItem moves the destination path, if existing,
18 // to the temporary directory passed in, and then moves the source hierarchy
19 // to the destination location. During rollback the original destination
20 // hierarchy is moved back.
21 class MoveTreeWorkItem : public WorkItem {
22 public:
23 virtual ~MoveTreeWorkItem();
24
25 virtual bool Do();
26
27 virtual void Rollback();
28
29 private:
30 friend class WorkItem;
31
32 // source_path specifies file or directory that will be moved to location
33 // specified by dest_path. To facilitate rollback, the caller needs to supply
34 // a temporary directory (temp_dir) to save the original files if they exist
35 // under dest_path.
36 MoveTreeWorkItem(const std::wstring& source_path,
37 const std::wstring& dest_path,
38 const std::wstring& temp_dir);
39
40 // Source path to move files from.
41 std::wstring source_path_;
42
43 // Destination path to move files to.
44 std::wstring dest_path_;
45
46 // Temporary directory to backup dest_path_ (if it already exists).
47 std::wstring temp_dir_;
48
49 // The full path in temp_dir_ where the original dest_path_ has
50 // been moved to.
51 std::wstring backup_path_;
52
53 // Whether the source was moved to dest_path_
54 bool moved_to_dest_path_;
55
56 // Whether the original files have been moved to backup path under
57 // temporary directory. If true, moving back is needed during rollback.
58 bool moved_to_backup_;
59 };
60
61 #endif // CHROME_INSTALLER_UTIL_MOVE_TREE_WORK_ITEM_H_
62
OLDNEW
« no previous file with comments | « chrome/installer/util/installer_unittests.vcproj ('k') | chrome/installer/util/move_tree_work_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698