forked from zlib-ng/minizip-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmz_os.h
146 lines (105 loc) · 4.19 KB
/
mz_os.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* mz_os.h -- System functions
Version 2.7.5, November 13, 2018
part of the MiniZip project
Copyright (C) 2010-2018 Nathan Moinvaziri
https://github.com/nmoinvaz/minizip
This program is distributed under the terms of the same license as zlib.
See the accompanying LICENSE file for the full text of the license.
*/
#ifndef MZ_OS_H
#define MZ_OS_H
#include <stdint.h>
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
#if defined(__APPLE__)
#define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_OSX_DARWIN)
#elif defined(unix)
#define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_UNIX)
#elif defined(_WIN32)
#define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_WINDOWS_NTFS)
#endif
#ifdef HAVE_LZMA
#define MZ_VERSION_MADEBY_ZIP_VERSION (63)
#elif HAVE_AES
#define MZ_VERSION_MADEBY_ZIP_VERSION (51)
#elif HAVE_BZIP2
#define MZ_VERSION_MADEBY_ZIP_VERSION (46)
#else
#define MZ_VERSION_MADEBY_ZIP_VERSION (45)
#endif
#define MZ_VERSION_MADEBY ((MZ_VERSION_MADEBY_HOST_SYSTEM << 8) | \
(MZ_VERSION_MADEBY_ZIP_VERSION))
/***************************************************************************/
#if defined(_WIN32)
struct dirent {
char d_name[256];
};
typedef void* DIR;
#else
#include <dirent.h>
#endif
/***************************************************************************/
// Shared functions
int32_t mz_path_combine(char *path, const char *join, int32_t max_path);
// Combines two paths
int32_t mz_path_compare_wc(const char *path, const char *wildcard, uint8_t ignore_case);
// Compare two paths with wildcard
int32_t mz_path_resolve(const char *path, char *target, int32_t max_target);
// Resolves path
int32_t mz_path_remove_filename(char *path);
// Remove the filename from a path
int32_t mz_path_get_filename(const char *path, const char **filename);
// Get the filename from a path
int32_t mz_dir_make(const char *path);
// Creates a directory recursively
int32_t mz_file_get_crc(const char *path, uint32_t *result_crc);
// Gets the crc32 hash of a file
/***************************************************************************/
// Platform specific functions
wchar_t *mz_os_unicode_string_create(const char *string, int32_t encoding);
// Create unicode string from a utf8 string
void mz_os_unicode_string_delete(wchar_t **string);
// Delete a unicode string that was created
uint8_t *mz_os_utf8_string_create(const char *string, int32_t encoding);
// Create a utf8 string from a string with another encoding
void mz_os_utf8_string_delete(uint8_t **string);
// Delete a utf8 string that was created
int32_t mz_os_rand(uint8_t *buf, int32_t size);
// Random number generator (not cryptographically secure)
int32_t mz_os_rename(const char *source_path, const char *target_path);
// Rename a file
int32_t mz_os_delete(const char *path);
// Delete an existing file
int32_t mz_os_file_exists(const char *path);
// Check to see if a file exists
int64_t mz_os_get_file_size(const char *path);
// Gets the length of a file
int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date);
// Gets a file's modified, access, and creation dates if supported
int32_t mz_os_set_file_date(const char *path, time_t modified_date, time_t accessed_date, time_t creation_date);
// Sets a file's modified, access, and creation dates if supported
int32_t mz_os_get_file_attribs(const char *path, uint32_t *attributes);
// Gets a file's attributes
int32_t mz_os_set_file_attribs(const char *path, uint32_t attributes);
// Sets a file's attributes
int32_t mz_os_make_dir(const char *path);
// Recursively creates a directory
DIR* mz_os_open_dir(const char *path);
// Opens a directory for listing
struct
dirent* mz_os_read_dir(DIR *dir);
// Reads a directory listing entry
int32_t mz_os_close_dir(DIR *dir);
// Closes a directory that has been opened for listing
int32_t mz_os_is_dir(const char *path);
// Checks to see if path is a directory
uint64_t mz_os_ms_time(void);
// Gets the time in milliseconds
/***************************************************************************/
#ifdef __cplusplus
}
#endif
#endif