aboutsummaryrefslogtreecommitdiff
path: root/Src/nde/android/vfs.h
blob: 25d06d8fbef2d138c8a19e607a0649bcc6d5b349 (plain) (blame)
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
#ifndef __NDE_VFS_H
#define __NDE_VFS_H

#include <foundation/types.h>
#include <stdio.h>

//#define NDE_ALLOW_NONCACHED

/*
#ifdef NDE_ALLOW_NONCACHED
  #ifndef NDE_NOWIN32FILEIO
    #error NDE_ALLOW_NONCACHED at least for now requires NDE_NOWIN32FILEIO
  #endif
#endif
*/

#define VFILE_INC 65536

#define VFS_READ        1
#define VFS_WRITE        2
#define VFS_SEEKEOF      4
#define VFS_CREATE      8
#define VFS_NEWCONTENT 16
#define VFS_MUSTEXIST  32

typedef struct {
    uint8_t *data;
    unsigned long ptr;
    unsigned long filesize;
    unsigned long maxsize;
    char *filename;
    char mode;
    int cached;
    int dirty;

#ifdef NDE_ALLOW_NONCACHED
    FILE *rfile;
#endif
	FILE *lockFile;
	char lockname[1024];

	int locks;
} VFILE;


#ifdef __cplusplus
extern "C" {
#endif

VFILE *Vfnew(const char *fl, const char *mode, int Cached);
VFILE *Vfopen(VFILE *f, const char *fl, const char *mode, int Cached);
size_t Vfread(void *ptr, size_t size, VFILE *buf);
void Vfseek(VFILE *fl, long i, int whence);
unsigned long Vftell(VFILE *fl);
void Vfclose(VFILE *fl);
void Vfdestroy(VFILE *fl); // benski> TODO: 
void Vfwrite(const void *ptr, size_t size, VFILE *f);
int Vfeof(VFILE *fl);
int Vsync(VFILE *fl); // 1 on error updating
int Vflock(VFILE *fl, bool is_sync=true); // returns 0 on failure
void Vfunlock(VFILE *fl, bool is_sync=true);
#ifdef __cplusplus
}
#endif

#endif