forked from salleaffaire/MP2TS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BinaryFile.hpp
63 lines (42 loc) · 925 Bytes
/
BinaryFile.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* BinaryFile.hpp
*
* Created on: Jul 3, 2015
* Author: luc.martel
*/
#ifndef BINARYFILE_HPP_
#define BINARYFILE_HPP_
#include <fstream>
#include <string>
#define OUT_FILE_BUFFER_SIZE (64*1024)
class BinaryInFile {
public:
BinaryInFile(std::string filename);
virtual ~BinaryInFile();
size_t GetSize();
uint8_t *GetDataPointer();
uint8_t &operator[](uint32_t index);
void Save(std::string filename);
protected:
BinaryInFile &self;
void Open();
std::string mFileName;
uint8_t *mData;
size_t mSize;
};
class BinaryOutFile {
public:
BinaryOutFile(std::string filename);
virtual ~BinaryOutFile();
bool Write(uint8_t *data, size_t size);
void Close();
protected:
std::string mFileName;
uint8_t *mData;
size_t mSize;
uint32_t mBufferSize;
uint32_t mPosition;
std::ofstream mOS;
void FlushBuffer();
};
#endif /* BINARYFILE_HPP_ */