Android-cuttlefish cvd tool
build_archive.h
Go to the documentation of this file.
1//
2// Copyright (C) 2025 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#pragma once
17
18#include <functional>
19#include <map>
20#include <optional>
21#include <ostream>
22#include <set>
23#include <string>
24#include <string_view>
25
32
33namespace cuttlefish {
34
43 public:
46 std::string_view archive_name);
48 static Result<BuildArchive> FromZipPath(const std::string&);
49
56 const std::set<std::string, std::less<void>>& Members() const;
57
70 std::string_view member_name,
71 std::optional<std::string_view> extract_dir);
72
73 Result<std::string> MemberContents(std::string_view name);
74
76
77 private:
78 BuildArchive(std::optional<FileSource>,
79 std::map<std::string, std::string, std::less<void>>,
80 std::set<std::string, std::less<void>>,
81 std::optional<ReadableZip>);
82
83 std::optional<FileSource> source_;
84 std::map<std::string, std::string, std::less<void>> extracted_;
85 std::set<std::string, std::less<void>> members_;
86 std::optional<ReadableZip> zip_file_;
87};
88
89// For libfmt
90std::string format_as(const BuildArchive&);
91
92std::ostream& operator<<(std::ostream&, const BuildArchive&);
93
96
97} // namespace cuttlefish
Definition: build_archive.h:42
friend PrettyStruct Pretty(const BuildArchive &, PrettyAdlPlaceholder unused)
Definition: build_archive.cc:178
std::set< std::string, std::less< void > > members_
Definition: build_archive.h:85
const std::set< std::string, std::less< void > > & Members() const
Definition: build_archive.cc:132
static Result< BuildArchive > FromZip(ReadableZip)
Definition: build_archive.cc:111
std::optional< ReadableZip > zip_file_
Definition: build_archive.h:86
static Result< BuildArchive > FromZipPath(const std::string &)
Definition: build_archive.cc:117
BuildArchive(std::optional< FileSource >, std::map< std::string, std::string, std::less< void > >, std::set< std::string, std::less< void > >, std::optional< ReadableZip >)
Definition: build_archive.cc:122
Result< std::string > MemberFilepath(std::string_view member_name, std::optional< std::string_view > extract_dir)
Definition: build_archive.cc:136
static Result< BuildArchive > FromFetcherConfig(const FetcherConfig &, FileSource, std::string_view archive_name)
Definition: build_archive.cc:65
std::map< std::string, std::string, std::less< void > > extracted_
Definition: build_archive.h:84
Result< std::string > MemberContents(std::string_view name)
Definition: build_archive.cc:158
std::optional< FileSource > source_
Definition: build_archive.h:83
Definition: fetcher_config.h:70
Definition: struct.h:60
Definition: archive.h:35
char * name
Definition: libf2fs.c:1403
Definition: alloc_driver.h:20
PrettyStruct Pretty(AndroidBuild &build, PrettyAdlPlaceholder)
Definition: android_build.cc:72
FileSource
Definition: file_source.h:31
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30
std::ostream & operator<<(std::ostream &out, DeviceType device_type)
Definition: device_type.cpp:72
std::string_view format_as(DeviceType device_type)
Definition: device_type.cpp:76
__u32 set
Definition: nl80211.h:1
Definition: pretty.h:20