-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMPAFileStream.h
More file actions
54 lines (41 loc) · 1.69 KB
/
MPAFileStream.h
File metadata and controls
54 lines (41 loc) · 1.69 KB
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
// GNU LESSER GENERAL PUBLIC LICENSE
// Version 3, 29 June 2007
//
// Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
//
// Everyone is permitted to copy and distribute verbatim copies of this license
// document, but changing it is not allowed.
//
// This version of the GNU Lesser General Public License incorporates the terms
// and conditions of version 3 of the GNU General Public License, supplemented
// by the additional permissions listed below.
#ifndef MPA_HEADER_INFO_MPA_FILE_STREAM_H_
#define MPA_HEADER_INFO_MPA_FILE_STREAM_H_
#include <cstdio> // FILE
#include "MPAStream.h"
#include "MPAFileSystem.h"
using HANDLE = void*;
class CMPAFileStream : public CMPAStream {
public:
CMPAFileStream(LPCTSTR file_name, IMPAFileSystem* file_system);
CMPAFileStream(LPCTSTR file_name, std::unique_ptr<IMPAFile>&& hFile);
virtual ~CMPAFileStream();
private:
static const unsigned INIT_BUFFERSIZE;
std::unique_ptr<IMPAFile> m_hFile;
// concerning read-buffer
mutable unsigned char* m_pBuffer;
mutable unsigned m_dwOffset; // offset (beginning if m_pBuffer)
mutable unsigned m_dwBufferSize;
void Init();
unsigned Read(void* data, unsigned offset, unsigned size) const;
bool FillBuffer(unsigned offset, unsigned size, bool should_reverse) const;
void SetPosition(unsigned offset) const;
protected:
// methods for file access (must be implemented by all derived classes)
virtual unsigned char* ReadBytes(unsigned size, unsigned& offset,
bool should_move_offset = true,
bool should_reverse = false) const;
virtual unsigned GetSize() const;
};
#endif // !MPA_HEADER_INFO_MPA_FILE_STREAM_H_