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 #ifndef DAV_SYSTEM_H
30 #define DAV_SYSTEM_H
31
32 #include <stdio.h>
33 #include <time.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36
37
38 #ifdef _WIN32
39 #include <Windows.h>
40 #define mode_t unsigned int
41 #else
42 #include <dirent.h>
43 #endif
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 typedef struct SysDirEnt {
50 char *name;
51 } SysDirEnt;
52
53 #ifdef _WIN32
54 struct WinDir {
55 int first;
56 HANDLE handle;
57 WIN32_FIND_DATAW finddata;
58 SysDirEnt *ent;
59 };
60 #define SYS_DIR struct WinDir*
61 #define SYS_STAT struct __stat64
62
63 typedef int uid_t;
64 typedef int gid_t;
65
66 #define SYS_ISLINK(path, mode) sys_islink(path)
67 #define SYS_LINK_EXT ".lnk"
68
69 #else
70
71 typedef struct SysDir {
72 DIR *dir;
73 SysDirEnt *ent;
74 } SysDir;
75
76 #define SYS_DIR SysDir*
77 #define SYS_STAT struct stat
78
79 #define SYS_ISLINK(p, s)
S_ISLNK(s.st_mode)
80
81 #endif
82
83 typedef int(*stat_func)(
const char*,
SYS_STAT *);
84
85 void sys_init(
void);
86 void sys_uninit(
void);
87
88 void sys_freedirent(SysDirEnt *ent);
89 SYS_DIR sys_opendir(
const char *path);
90 SysDirEnt* sys_readdir(
SYS_DIR dir);
91 void sys_closedir(
SYS_DIR dir);
92
93 FILE* sys_fopen(
const char *path,
const char *mode);
94
95 int sys_stat(
const char *path,
SYS_STAT *s);
96 int sys_lstat(
const char *path,
SYS_STAT *s);
97
98 int sys_islink(
const char *path);
99
100 int sys_rename(
const char *oldpath,
const char *newpath);
101 int sys_unlink(
const char *path);
102 int sys_mkdir(
const char *path);
103
104 char* sys_readlink(
const char *path,
SYS_STAT *s);
105
106 int sys_symlink(
const char *target,
const char *linkpath);
107
108 int sys_truncate(
const char* path,
off_t length);
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif
115
116