Android-cuttlefish cvd tool
source_reader.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 <stdint.h>
19
20#include <mutex>
21
26
27namespace cuttlefish {
28
29/* A `ReadableZipSource` in an "open for reading" state. */
30class ZipSourceReader : public Reader {
31 public:
32 /* Makes the source "open for reading." Should not outlive the source. */
34
36 virtual ~ZipSourceReader();
38
39 /* Returns a failed Result on error, or a successful result with bytes read or
40 * 0 on EOF. */
41 Result<uint64_t, int> Read(void* data, uint64_t length) override;
42
43 Result<void> Visit(IoVisitor&) override;
44
45 private:
47
49
50 void Close();
51
53 std::recursive_mutex mutex_;
54};
55
56} // namespace cuttlefish
Definition: io.h:45
Definition: readable_source.h:24
Definition: reader.h:25
Definition: seeking_source_reader.h:29
Definition: source_reader.h:30
Result< uint64_t, int > Read(void *data, uint64_t length) override
Definition: source_reader.cc:65
ReadableZipSource * source_
Definition: source_reader.h:52
Result< void > Visit(IoVisitor &) override
Definition: source_reader.cc:80
ZipSourceReader(ZipSourceReader &&)
Definition: source_reader.cc:44
std::recursive_mutex mutex_
Definition: source_reader.h:53
static Result< ZipSourceReader > Open(ReadableZipSource &)
Definition: source_reader.cc:34
void Close()
Definition: source_reader.cc:58
virtual ~ZipSourceReader()
Definition: source_reader.cc:56
ZipSourceReader & operator=(ZipSourceReader &&)
Definition: source_reader.cc:47
char data[Size]
Definition: incremental_server.cpp:1
Definition: alloc_driver.h:21
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30