Android-cuttlefish cvd tool
seeking_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
25
26namespace cuttlefish {
27
28/* A `SeekableZipSource` in an "open for reading" state. */
30 public:
31 /* Makes the source "open for reading." Should not outlive the source. */
33
35 ~SeekingZipSourceReader() override = default;
37
38 Result<void> Visit(IoVisitor&) override;
39
40 Result<uint64_t, int> Read(void* data, uint64_t length) override;
41 Result<uint64_t, int> PRead(void* buf, uint64_t count,
42 uint64_t offset) const override;
43
44 Result<uint64_t, int> SeekSet(uint64_t offset) override;
45 Result<uint64_t, int> SeekCur(int64_t offset) override;
46 Result<uint64_t, int> SeekEnd(int64_t offset) override;
47
48 private:
50
51 Result<uint64_t, int> Seek(int64_t offset, int whence);
52};
53
54} // namespace cuttlefish
Definition: io.h:45
Definition: reader_seeker.h:29
Definition: seekable_source.h:27
Definition: seeking_source_reader.h:29
Result< uint64_t, int > Seek(int64_t offset, int whence)
Definition: seeking_source_reader.cc:72
SeekingZipSourceReader & operator=(SeekingZipSourceReader &&)=default
Result< uint64_t, int > Read(void *data, uint64_t length) override
Definition: seeking_source_reader.cc:64
SeekingZipSourceReader(SeekingZipSourceReader &&)=default
static Result< SeekingZipSourceReader > Open(SeekableZipSource &)
Definition: seeking_source_reader.cc:38
Result< void > Visit(IoVisitor &) override
Definition: seeking_source_reader.cc:47
Result< uint64_t, int > PRead(void *buf, uint64_t count, uint64_t offset) const override
Definition: seeking_source_reader.cc:93
~SeekingZipSourceReader() override=default
Result< uint64_t, int > SeekEnd(int64_t offset) override
Definition: seeking_source_reader.cc:60
Result< uint64_t, int > SeekCur(int64_t offset) override
Definition: seeking_source_reader.cc:56
Result< uint64_t, int > SeekSet(uint64_t offset) override
Definition: seeking_source_reader.cc:52
Definition: source_reader.h:30
friend class SeekingZipSourceReader
Definition: source_reader.h:46
char data[Size]
Definition: incremental_server.cpp:1
Definition: alloc_driver.h:21
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30