1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-13 11:42:18 +00:00
ton/validator/db/package.hpp

34 lines
752 B
C++
Raw Normal View History

#pragma once
#include "td/actor/actor.h"
#include "td/utils/port/FileFd.h"
#include "td/utils/buffer.h"
namespace ton {
class Package {
public:
static td::Result<Package> open(std::string path, bool read_only = false, bool create = false);
Package(td::FileFd fd);
td::Status truncate(td::uint64 size);
2019-11-15 14:02:37 +00:00
td::uint64 append(std::string filename, td::Slice data, bool sync = true);
void sync();
td::uint64 size() const;
td::Result<std::pair<std::string, td::BufferSlice>> read(td::uint64 offset) const;
2019-11-15 14:02:37 +00:00
td::Result<td::uint64> advance(td::uint64 offset);
void iterate(std::function<bool(std::string, td::BufferSlice, td::uint64)> func);
2019-11-15 14:02:37 +00:00
td::FileFd &fd() {
return fd_;
}
private:
td::FileFd fd_;
};
} // namespace ton