• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright (C) 2023 The Android Open Source Project
3   *
4   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *      http://www.apache.org/licenses/LICENSE-2.0
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  #pragma once
18  
19  #include <functional>
20  #include <string>
21  
22  #include "common/libs/utils/result.h"
23  #include "host/libs/config/cuttlefish_config.h"
24  
25  namespace cuttlefish {
26  
27  /*
28   * Copy recursively from src_dir_path to dest_dir_path as long as
29   * the predicate function returns true
30   */
31  Result<void> CopyDirectoryRecursively(
32      const std::string& src_dir_path, const std::string& dest_dir_path,
33      const bool verify_dest_dir_empty = false,
34      std::function<bool(const std::string&)> predicate = [](const std::string&) {
35        return true;
36      });
37  
38  Result<Json::Value> CreateMetaInfo(const CuttlefishConfig& config,
39                                     const std::string& snapshot_path);
40  
41  Result<std::string> InstanceGuestSnapshotPath(const Json::Value& meta_json,
42                                                const std::string& instance_id);
43  std::string SnapshotMetaJsonPath(const std::string& snapshot_path);
44  Result<Json::Value> LoadMetaJson(const std::string& snapshot_path);
45  
46  Result<std::vector<std::string>> GuestSnapshotDirectories(
47      const std::string& snapshot_path);
48  
49  inline constexpr const char kMetaInfoJsonFileName[] = "snapshot_meta_info.json";
50  inline constexpr const char kGuestSnapshotField[] = "guest_snapshot";
51  inline constexpr const char kSnapshotPathField[] = "snapshot_path";
52  inline constexpr const char kCfHomeField[] = "HOME";
53  inline constexpr const char kGuestSnapshotBase[] = "guest_vm";
54  
55  }  // namespace cuttlefish
56