Android-cuttlefish cvd tool
sparse_image.h
Go to the documentation of this file.
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 <stdint.h>
20
21#include <memory>
22#include <string>
23
26
27namespace cuttlefish {
28
29Result<void> ForceRawImage(const std::string& image_path);
30Result<bool> IsSparseImage(const std::string& image_path);
31Result<void> ConvertSparseImageToRaw(const std::string& source_path,
32 const std::string& destination_path);
33
37 public:
38 static Result<AndroidSparseImage> OpenExisting(const std::string& path);
39
43
50 static std::string MagicString();
51
52 Result<uint64_t> VirtualSizeBytes() const override;
53 Result<std::string> QemuImgName() const override;
54
55 private:
56 struct Impl;
57
58 AndroidSparseImage(std::unique_ptr<Impl>);
59
60 std::unique_ptr<Impl> impl_;
61};
62
63} // namespace cuttlefish
Definition: sparse_image.h:36
std::unique_ptr< Impl > impl_
Definition: sparse_image.h:60
static Result< AndroidSparseImage > OpenExisting(const std::string &path)
Definition: sparse_image.cc:109
AndroidSparseImage & operator=(AndroidSparseImage &&)
Definition: sparse_image.cc:136
Result< uint64_t > VirtualSizeBytes() const override
Definition: sparse_image.cc:145
Result< std::string > QemuImgName() const override
Definition: sparse_image.cc:153
AndroidSparseImage(AndroidSparseImage &&)
Definition: sparse_image.cc:130
AndroidSparseImage(std::unique_ptr< Impl >)
static std::string MagicString()
Definition: sparse_image.cc:141
Definition: disk_image.h:26
Definition: alloc_driver.h:21
Result< void > ForceRawImage(const std::string &image_path)
Definition: sparse_image.cc:83
Result< void > ConvertSparseImageToRaw(const std::string &source_path, const std::string &destination_path)
Definition: sparse_image.cc:71
Result< bool > IsSparseImage(const std::string &image_path)
Definition: sparse_image.cc:61
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
Definition: sparse_image.cc:104