29#include <unordered_map>
64 const std::unordered_map<std::
string, std::
string> &config = {},
65 std::vector<std::unique_ptr<OperatorOption>> options = {});
92 std::
string Read(std::string_view path);
109 void Write(std::string_view path, std::string_view data);
118 void Write(std::string_view path, std::string_view data,
138 [[deprecated(
"Use Exists() instead.")]]
162 void Copy(std::string_view src, std::string_view dst);
163 void Copy(std::string_view src, std::string_view dst,
172 void Rename(std::string_view src, std::string_view dst);
173 void Rename(std::string_view src, std::string_view dst,
209 void Destroy() noexcept;
229 std::streamsize
Read(
void *s, std::streamsize n);
231 std::streamsize
ReadAt(
void *s, std::streamsize n, uint64_t offset);
233 std::streampos
Seek(std::streamoff off, std::ios_base::seekdir way);
240 void Destroy() noexcept;
269 void Destroy() noexcept;
285 : reader_(std::move(reader)), buffer_start_pos_(0) {
286 setg(buffer_, buffer_, buffer_);
290 std::streamsize
xsgetn(
char *s, std::streamsize count)
override {
291 std::streamsize total_read = 0;
293 while (total_read < count) {
294 if (gptr() < egptr()) {
295 std::streamsize available_bytes = egptr() - gptr();
296 std::streamsize to_copy =
297 (std::min)(available_bytes, count - total_read);
298 std::memcpy(s + total_read, gptr(), to_copy);
300 total_read += to_copy;
304 if (
underflow() == traits_type::eof())
break;
311 if (gptr() < egptr()) {
312 return traits_type::to_int_type(*gptr());
316 buffer_start_pos_ +=
static_cast<std::streamoff
>(egptr() - eback());
318 std::streamsize n = reader_.Read(buffer_,
sizeof(buffer_));
320 return traits_type::eof();
323 setg(buffer_, buffer_, buffer_ + n);
324 return traits_type::to_int_type(*gptr());
329 if (result != traits_type::eof()) {
335 std::streampos
seekoff(std::streamoff off, std::ios_base::seekdir dir,
336 std::ios_base::openmode which)
override {
337 if (dir == std::ios_base::cur && off == 0) {
339 return buffer_start_pos_ +
static_cast<std::streamoff
>(gptr() - eback());
343 std::streampos new_pos = reader_.Seek(off, dir);
344 if (new_pos != std::streampos(-1)) {
345 buffer_start_pos_ = new_pos;
346 setg(buffer_, buffer_, buffer_);
352 std::ios_base::openmode which)
override {
353 return seekoff(pos, std::ios_base::beg, which);
359 std::streampos buffer_start_pos_;
363 : std::istream(&buf_), buf_(std::move(reader)) {}
366 ReaderStreamBuf buf_;
402 current_entry_ = lister_.
Next();
408 if (current_entry_) {
409 current_entry_ = lister_.Next();
415 return current_entry_ != std::nullopt ||
416 other.current_entry_ != std::nullopt;
427 std::optional<Entry> current_entry_;
443 Lister(ffi::Lister *pointer)
noexcept;
445 void Destroy() noexcept;
Definition data_structure.hpp:340
The entry of a file or directory.
Definition data_structure.hpp:190
Definition opendal.hpp:393
std::ptrdiff_t difference_type
Definition opendal.hpp:397
Entry operator*()
Definition opendal.hpp:405
Entry * pointer
Definition opendal.hpp:398
Entry value_type
Definition opendal.hpp:396
Iterator(Lister &lister)
Definition opendal.hpp:401
Entry & reference
Definition opendal.hpp:399
std::input_iterator_tag iterator_category
Definition opendal.hpp:395
friend class Lister
Definition opendal.hpp:424
Iterator(Lister &lister, bool) noexcept
Definition opendal.hpp:421
Iterator & operator++()
Definition opendal.hpp:407
bool operator!=(const Iterator &other) const
Definition opendal.hpp:414
Lister is designed to list the entries of a directory.
Definition opendal.hpp:381
friend class Operator
Definition opendal.hpp:441
std::optional< Entry > Next()
Get the next entry of the lister.
Lister(Lister &&other) noexcept
Iterator begin()
Definition opendal.hpp:437
Iterator end()
Definition opendal.hpp:438
void RemoveAll(const std::vector< std::string > &paths)
void Remove(std::string_view path)
Remove a file or directory.
Reader GetReader(std::string_view path)
Read data from the operator.
void Rename(std::string_view src, std::string_view dst)
Rename a file from src to dst.
Operator(Operator &&other) noexcept
bool Exists(std::string_view path)
Check if the path exists.
bool Available() const
Check if the operator is available.
std::string Read(std::string_view path)
Read data from the operator.
Operator(const Operator &)=delete
bool IsExist(std::string_view path)
Check if the path exists.
Operator & operator=(const Operator &)=delete
Lister GetLister(std::string_view path)
void CreateDir(std::string_view path)
Create a directory.
Operator & operator=(Operator &&other) noexcept
void Copy(std::string_view src, std::string_view dst)
Copy a file from src to dst.
Writer GetWriter(std::string_view path)
void Write(std::string_view path, std::string_view data)
Write data to the operator.
std::vector< Entry > List(std::string_view path)
List the entries of a directory.
Metadata Stat(std::string_view path)
Get the metadata of a file or directory.
int_type uflow() override
Definition opendal.hpp:327
std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which) override
Definition opendal.hpp:335
std::streamsize xsgetn(char *s, std::streamsize count) override
Definition opendal.hpp:290
int_type underflow() override
Definition opendal.hpp:310
std::streampos seekpos(std::streampos pos, std::ios_base::openmode which) override
Definition opendal.hpp:351
ReaderStreamBuf(Reader &&reader)
Definition opendal.hpp:284
ReaderStream(Reader &&reader)
Definition opendal.hpp:362
Reader is designed to read data from the operator.
Definition opendal.hpp:223
Reader(Reader &&other) noexcept
friend class Operator
Definition opendal.hpp:236
std::streamsize ReadAt(void *s, std::streamsize n, uint64_t offset)
std::streamsize Read(void *s, std::streamsize n)
std::streampos Seek(std::streamoff off, std::ios_base::seekdir way)
Writer is designed to write a sequence of byte buffers to an object.
Definition opendal.hpp:252
friend class Operator
Definition opendal.hpp:265
void Write(std::string_view data)
Writer(Writer &&other) noexcept
Definition data_structure.hpp:29
Options for copy operations.
Definition data_structure.hpp:300
Options for delete operations.
Definition data_structure.hpp:321
Options for list and lister operations.
Definition data_structure.hpp:330
Options for read operations.
Definition data_structure.hpp:245
Options for creating readers.
Definition data_structure.hpp:265
Options for rename operations.
Definition data_structure.hpp:313
Options for stat operations.
Definition data_structure.hpp:230
Options for write and writer operations.
Definition data_structure.hpp:282