-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileWrapper.h
45 lines (34 loc) · 934 Bytes
/
FileWrapper.h
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
#ifndef EXTERNAL_SORT_FILEWRAPPER_H
#define EXTERNAL_SORT_FILEWRAPPER_H
#if defined(__MINGW32__)
#define __MSVCRT_VERSION__ 0x900
#elif defined(_MSC_VER)
#include <cstdint>
#endif
#include <stdio.h>
#include "Range.h"
namespace external_sort
{
class FileWrapper {
public:
FileWrapper(); // temporary file
FileWrapper(const char* fileName, bool input);
FileWrapper(FileWrapper&& tmp);
~FileWrapper();
size_t Read(int64_t offset, char* const chunk, size_t chunkSize) const;
void Write(const RangeConstChar& range) const;
void Close();
int64_t GetFileSize() const;
void Rewind() const;
bool IsEOF() const;
void WriteNumbers(size_t numbers[], size_t count) const;
bool ReadNumbers(size_t numbers[], size_t count) const;
private:
FileWrapper(const FileWrapper&);
void operator=(const FileWrapper&);
private:
std::FILE* m_file;
int64_t m_size;
};
}
#endif //EXTERNAL_SORT_FILEWRAPPER_H