-
Notifications
You must be signed in to change notification settings - Fork 16
/
zpath.h
117 lines (96 loc) · 3.51 KB
/
zpath.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach )
http://www.zsnes.com
http://sourceforge.net/projects/zsnes
https://zsnes.bountysource.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef ZPATH_H
#define ZPATH_H
#include <stdio.h>
#include <sys/stat.h>
#include <zlib.h>
#include "zip/zunzip.h"
#ifndef NO_JMA
#include "jma/zsnesjma.h"
#endif
#ifdef _MSC_VER
#define F_OK 0
#define X_OK F_OK // Drop down to F_OK because MSVC is stupid
#define W_OK 2
#define R_OK 4
typedef unsigned short mode_t;
#endif
#if !defined(__cplusplus) && !defined(bool)
// C++ style code in C
#include <stdbool.h>
#endif
#ifdef __UNIXSDL__
#define DIR_SLASH "/"
#define DIR_SLASH_C '/'
#define DIR_SLASH_C_OTHER '\\'
#define ROOT_LEN 1 //"/"
#define DIR_R_ACCESS (R_OK | X_OK)
#define IS_ABSOLUTE(path) ((*(path) == '/') || (*(path) == '~'))
#else
#define DIR_SLASH "\\"
#define DIR_SLASH_C '\\'
#define DIR_SLASH_C_OTHER '/'
#define ROOT_LEN 3 //"A:\"
#define DIR_R_ACCESS (F_OK)
#define IS_ABSOLUTE(path) ((*(path) == '\\') || (*(path) && ((path)[1] == ':')))
#endif
#define PATH_SIZE 4096
#define NAME_SIZE 512
#define realpath_native realpath
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
extern char ZCfgFile[];
extern char *ZStartPath, *ZCfgPath, *ZSramPath, *ZRomPath;
extern char *ZSnapPath, *ZSpcPath, *ZIpsPath, *ZMoviePath;
extern char *ZChtPath, *ZComboPath, *ZInpPath, *ZSStatePath;
extern char *ZCartName, *ZSaveName, *ZStateName, *ZSaveST2Name;
bool init_paths(char* launch_command);
void init_save_paths(void);
bool init_rom_path(char* path);
char* strdupcat(const char* str1, const char* str2);
int access_dir(const char* path, const char* file, int mode);
int stat_dir(const char* path, const char* file, struct stat* buf);
FILE* fopen_dir(const char* path, const char* file, const char* mode);
gzFile gzopen_dir(const char* path, const char* file, const char* mode);
unzFile unzopen_dir(const char* path, const char* file);
#ifndef NO_JMA
void load_jma_file_dir(const char* path, const char* file);
#endif
int remove_dir(const char* path, const char* file);
int mkdir_dir(const char* path, const char* dir);
char* realpath_dir(const char* path, const char* file, char* buf);
FILE* fdreopen_dir(const char* path, const char* file, const char* mode, int fd);
int system_dir(const char* path, const char* command);
FILE* popen_dir(const char* path, char* command, const char* type);
void natify_slashes(char* str);
char* strcutslash(char* str);
char* strcatslash(char* str);
void setextension(char* base, const char* ext);
bool isextension(const char* fname, const char* ext);
void strdirname(char* str);
void strbasename(char* str);
bool mkpath(const char* path, mode_t mode);
#ifdef __UNIXSDL__
char* realpath_link(const char* path, char* resolved_path);
char* realpath_tilde(const char* path, char* resolved_path);
#else
#define realpath_link realpath_native
#endif
void psr_cfg_run(unsigned char (*psr_func)(const char*), const char* dir, const char* fname);
#endif