userver: userver/dump/operations_file.hpp Source File
Loading...
Searching...
No Matches
operations_file.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <filesystem>
7
11
14
15USERVER_NAMESPACE_BEGIN
16
17namespace dump {
18
20class FileWriter final : public Writer {
21public:
27 explicit FileWriter(std::string path, std::filesystem::perms perms, tracing::ScopeTime& scope);
28
29 void Finish() override;
30
31private:
32 void WriteRaw(std::string_view data) override;
33
35 std::string final_path_;
36 std::string path_;
37 std::filesystem::perms perms_;
38 utils::StreamingCpuRelax cpu_relax_;
39};
40
42class FileReader final : public Reader {
43public:
46 explicit FileReader(std::string path);
47
48 void Finish() override;
49
50private:
51 std::string_view ReadRaw(std::size_t max_size) override;
52
53 void BackUp(std::size_t size) override;
54
56 std::string path_;
57 std::string curr_chunk_;
58};
59
61public:
63 explicit FileOperationsFactory(std::filesystem::perms perms);
64
65 std::unique_ptr<Reader> CreateReader(std::string full_path) override;
66
67 std::unique_ptr<Writer> CreateWriter(std::string full_path, tracing::ScopeTime& scope) override;
68
69private:
70 const std::filesystem::perms perms_;
71};
72
73} // namespace dump
74
75USERVER_NAMESPACE_END