create_dir_work_item.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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_CREATE_DIR_WORK_ITEM_H_
6#define CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
7
8#include <windows.h>
9
10#include "base/files/file_path.h"
11#include "chrome/installer/util/work_item.h"
12
13// A WorkItem subclass that creates a directory with the specified path.
14// It also creates all necessary intermediate paths if they do not exist.
15class CreateDirWorkItem : public WorkItem {
16 public:
17  virtual ~CreateDirWorkItem();
18
19  virtual bool Do();
20
21  // Rollback tries to remove all directories created along the path.
22  // If the leaf directory or one of the intermediate directories are not
23  // empty, the non-empty directory and its parent directories will not be
24  // removed.
25  virtual void Rollback();
26
27 private:
28  friend class WorkItem;
29
30  explicit CreateDirWorkItem(const base::FilePath& path);
31
32  // Get the top most directory that needs to be created in order to create
33  // "path_", and set "top_path_" accordingly. if "path_" already exists,
34  // "top_path_" is set to empty string.
35  void GetTopDirToCreate();
36
37  // Path of the directory to be created.
38  base::FilePath path_;
39
40  // The top most directory that needs to be created.
41  base::FilePath top_path_;
42
43  bool rollback_needed_;
44};
45
46#endif  // CHROME_INSTALLER_UTIL_CREATE_DIR_WORK_ITEM_H_
47