Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
compressed_file.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <ios>
4#include <fc/io/cfile.hpp>
5
6namespace sysio::trace_api {
7
8 class compressed_file_datastream;
9 struct compressed_file_impl;
46 public:
47 explicit compressed_file( fc::path file_path );
49
55
56
60 void open() {
61 file_ptr = std::make_unique<fc::cfile>();
62 file_ptr->set_file_path(file_path);
63 file_ptr->open("rb");
64 }
65
71 bool is_open() const { return (bool)file_ptr; }
72
79 void seek( long loc );
80
91 void read( char* d, size_t n );
92
96 void close() {
97 file_ptr.reset();
98 }
99
104 auto get_file_path() const {
105 return file_path;
106 }
107
109
120 static bool process( const fc::path& input_path, const fc::path& output_path, size_t seek_point_stride );
121
122 private:
123 fc::path file_path;
124 std::unique_ptr<fc::cfile> file_ptr;
125 std::unique_ptr<compressed_file_impl> impl;
126 };
127
128 /*
129 * @brief datastream adapter that adapts cfile for use with fc unpack
130 *
131 * This class supports unpack functionality but not pack.
132 */
134 public:
135 explicit compressed_file_datastream( compressed_file& cf ) : cf(cf) {}
136
137 void skip( size_t s ) {
138 std::vector<char> d( s );
139 read( &d[0], s );
140 }
141
142 bool read( char* d, size_t s ) {
143 cf.read( d, s );
144 return true;
145 }
146
147 bool get( unsigned char& c ) { return get( *(char*)&c ); }
148
149 bool get( char& c ) { return read(&c, 1); }
150
151 private:
152 compressed_file& cf;
153 };
154
158
163 class compressed_file_error : public std::runtime_error {
164 public:
165 using std::runtime_error::runtime_error;
166 };
167
168}
wraps boost::filesystem::path to provide platform independent path manipulation.
compressed_file_datastream create_datastream()
compressed_file & operator=(compressed_file &&)
compressed_file(compressed_file &&)
static bool process(const fc::path &input_path, const fc::path &output_path, size_t seek_point_stride)
CK_ULONG d
char * s