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
25#include "absl/strings/string_view.h"
26
33
34namespace cuttlefish {
35
44 public:
47 absl::string_view archive_name);
49 static Result<BuildArchive> FromZipPath(const std::string&);
50
57 const std::set<std::string, std::less<void>>& Members() const;
58
71 absl::string_view member_name,
72 std::optional<absl::string_view> extract_dir);
73
74 Result<std::string> MemberContents(absl::string_view name);
75
77
78 private:
79 BuildArchive(std::optional<FileSource>,
80 std::map<std::string, std::string, std::less<void>>,
81 std::set<std::string, std::less<void>>,
82 std::optional<ReadableZip>);
83
84 std::optional<FileSource> source_;
85 std::map<std::string, std::string, std::less<void>> extracted_;
86 std::set<std::string, std::less<void>> members_;
87 std::optional<ReadableZip> zip_file_;
88};
89
90// For libfmt
91std::string format_as(const BuildArchive&);
92
93std::ostream& operator<<(std::ostream&, const BuildArchive&);
94
97
98} // namespace cuttlefish
Definition: build_archive.h:43
friend PrettyStruct Pretty(const BuildArchive &, PrettyAdlPlaceholder unused)
Definition: build_archive.cc:179
std::set< std::string, std::less< void > > members_
Definition: build_archive.h:86
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
Result< std::string > MemberFilepath(absl::string_view member_name, std::optional< absl::string_view > extract_dir)
Definition: build_archive.cc:136
std::optional< ReadableZip > zip_file_
Definition: build_archive.h:87
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 > MemberContents(absl::string_view name)
Definition: build_archive.cc:159
static Result< BuildArchive > FromFetcherConfig(const FetcherConfig &, FileSource, absl::string_view archive_name)
Definition: build_archive.cc:65
std::map< std::string, std::string, std::less< void > > extracted_
Definition: build_archive.h:85
std::optional< FileSource > source_
Definition: build_archive.h:84
Definition: fetcher_config.h:70
Definition: struct.h:60
Definition: archive.h:36
Definition: alloc_driver.h:21
PrettyStruct Pretty(AndroidBuild &build, PrettyAdlPlaceholder)
Definition: android_build.cc:73
FileSource
Definition: file_source.h:33
std::ostream & operator<<(std::ostream &out, DeviceType device_type)
Definition: device_type.cpp:73
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
std::string_view format_as(DeviceType device_type)
Definition: device_type.cpp:77
__u32 set
Definition: nl80211.h:1
Definition: pretty.h:20