forked from chundongwang/untrunc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.h
58 lines (45 loc) · 1.48 KB
/
file.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
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Untrunc - file.h
Untrunc is GPL software; you can freely distribute,
redistribute, modify & use under the terms of the GNU General
Public License; either version 2 or its successor.
Untrunc is distributed under the GPL "AS IS", without
any warranty; without the implied warranty of merchantability
or fitness for either an expressed or implied particular purpose.
Please see the included GNU General Public License (GPL) for
your rights and further details; see the file COPYING. If you
cannot, write to the Free Software Foundation, 59 Temple Place
Suite 330, Boston, MA 02111-1307, USA. Or www.fsf.org
Copyright 2010 Federico Ponchio
*/
#ifndef FILE_H
#define FILE_H
extern "C" {
#include <stdint.h>
}
#include <stdio.h>
#include <vector>
#include <string>
class File {
public:
File();
~File();
bool open(std::string filename);
bool create(std::string filename);
void seek(off_t p);
off_t pos();
bool atEnd();
off_t length() { return size; }
int readInt();
int64_t readInt64();
void readChar(char *dest, size_t n);
std::vector<unsigned char> read(size_t n);
int writeInt(int n);
int writeInt64(int64_t n);
int writeChar(char *source, size_t n);
int write(std::vector<unsigned char> &v);
protected:
off_t size;
FILE *file;
};
#endif // FILE_H