-
Notifications
You must be signed in to change notification settings - Fork 0
/
LargeFileSources.cpp
75 lines (54 loc) · 1.37 KB
/
LargeFileSources.cpp
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
64
65
66
67
68
69
70
71
72
73
74
75
#include "stdafx.h"
#include "Mp4File.h"
#include "Mp4IStreamSource.h"
LargeIfstream::LargeIfstream(const char* filename) {
file = fopen(filename, "rb");
badF = (file == 0);
}
LargeIfstream::~LargeIfstream() {
if (file) fclose(file);
}
bool LargeIfstream::bad() {
return badF || ( ferror(file)!=0);
}
bool LargeIfstream::eof() {
return feof(file);
}
void LargeIfstream::read(char* buffer, uint64_t size) {
badF = fread(buffer, size, 1, file) != 1;
}
void LargeIfstream::seekg(uint64_t pos, int from) {
if (fseek(file, pos, from) != 0) badF = true;
//if (_fseeki64(file, pos, from) != 0) badF = true;
}
uint64_t LargeIfstream::tellg() {
uint64_t pos = ftell(file);
//uint64_t pos = _ftelli64(file);
return pos;
}
void LargeIfstream::clear() {
badF = true;
}
bool LargeIfstream::fail() {
return ferror(file)!=0;
}
LargeOfstream::LargeOfstream(const char* filename) {
file = fopen(filename, "wb");
badF = (file == 0);
}
LargeOfstream::~LargeOfstream() {
if (file) fclose(file);
}
void LargeOfstream::flush() {
fflush(file);
};
bool LargeOfstream::bad() {
return ( badF || (ferror(file)!=0));
}
uint64_t LargeOfstream::tellp() {
// return _ftelli64(file);
return ftell(file);
}
void LargeOfstream::write(const char* buffer, uint64_t size) {
badF = fwrite(buffer, size, 1, file) != 1;
}