-
Notifications
You must be signed in to change notification settings - Fork 156
/
filepath.h
47 lines (36 loc) · 1.14 KB
/
filepath.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
#ifndef HACTOOL_FILEPATH_H
#define HACTOOL_FILEPATH_H
#include "types.h"
#include "utils.h"
typedef uint16_t utf16char_t;
#ifdef _WIN32
typedef wchar_t oschar_t; /* utf-16 */
#define os_fopen _wfopen
#define OS_MODE_READ L"rb"
#define OS_MODE_WRITE L"wb"
#define OS_MODE_EDIT L"rb+"
#define OS_PATH_SEPARATOR "\\"
#else
typedef char oschar_t; /* utf-8 */
#define os_fopen fopen
#define OS_MODE_READ "rb"
#define OS_MODE_WRITE "wb"
#define OS_MODE_EDIT "rb+"
#define OS_PATH_SEPARATOR "/"
#endif
typedef struct filepath {
char char_path[MAX_PATH];
oschar_t os_path[MAX_PATH];
validity_t valid;
} filepath_t;
void os_strcpy(oschar_t *dst, const char *src);
int os_makedir(const oschar_t *dir);
int os_rmdir(const oschar_t *dir);
void filepath_init(filepath_t *fpath);
void filepath_copy(filepath_t *fpath, filepath_t *copy);
void filepath_append(filepath_t *fpath, const char *format, ...);
void filepath_append_n(filepath_t *fpath, uint32_t n, const char *format, ...);
void filepath_set(filepath_t *fpath, const char *path);
void filepath_set_format(filepath_t *fpath, const char *format, ...);
oschar_t *filepath_get(filepath_t *fpath);
#endif