| 1 | /* mz_os.h -- System functions |
| 2 | part of the minizip-ng project |
| 3 | |
| 4 | Copyright (C) Nathan Moinvaziri |
| 5 | https://github.com/zlib-ng/minizip-ng |
| 6 | |
| 7 | This program is distributed under the terms of the same license as zlib. |
| 8 | See the accompanying LICENSE file for the full text of the license. |
| 9 | */ |
| 10 | |
| 11 | #ifndef MZ_OS_H |
| 12 | #define MZ_OS_Hcxx . . $ `mz_os.h:12:9`! |
| 13 | |
| 14 | #ifdef __cplusplus |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | /***************************************************************************/ |
| 19 | |
| 20 | #if defined(__APPLE__) |
| 21 | # define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_OSX_DARWIN) |
| 22 | #elif defined(__riscos__) |
| 23 | # define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_RISCOS) |
| 24 | #elif defined(_WIN32) |
| 25 | # define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_WINDOWS_NTFS) |
| 26 | #else |
| 27 | # define MZ_VERSION_MADEBY_HOST_SYSTEMcxx . . $ `mz_os.h:27:11`! (MZ_HOST_SYSTEM_UNIX) |
| 28 | #endif |
| 29 | |
| 30 | #if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) |
| 31 | # define MZ_VERSION_MADEBY_ZIP_VERSION (63) |
| 32 | #elif defined(HAVE_WZAEScxx . . $ `<built-in>:416:9`!) |
| 33 | # define MZ_VERSION_MADEBY_ZIP_VERSIONcxx . . $ `mz_os.h:33:11`! (51) |
| 34 | #elif defined(HAVE_BZIP2) |
| 35 | # define MZ_VERSION_MADEBY_ZIP_VERSION (46) |
| 36 | #else |
| 37 | # define MZ_VERSION_MADEBY_ZIP_VERSION (45) |
| 38 | #endif |
| 39 | |
| 40 | #define MZ_VERSION_MADEBYcxx . . $ `mz_os.h:40:9`! ((MZ_VERSION_MADEBY_HOST_SYSTEM << 8) | (MZ_VERSION_MADEBY_ZIP_VERSION)) |
| 41 | |
| 42 | #define MZ_PATH_SLASH_UNIXcxx . . $ `mz_os.h:42:9`! ('/') |
| 43 | #define MZ_PATH_SLASH_WINDOWScxx . . $ `mz_os.h:43:9`! ('\\') |
| 44 | #if defined(_WIN32) |
| 45 | # define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_WINDOWS) |
| 46 | #else |
| 47 | # define MZ_PATH_SLASH_PLATFORMcxx . . $ `mz_os.h:47:11`! (MZ_PATH_SLASH_UNIXcxx . . $ `mz_os.h:42:9`!) |
| 48 | #endif |
| 49 | |
| 50 | /***************************************************************************/ |
| 51 | |
| 52 | #if defined(_WIN32) |
| 53 | struct dirent { |
| 54 | char d_name[256]; |
| 55 | }; |
| 56 | typedef void *DIR; |
| 57 | #else |
| 58 | # include <dirent.h> |
| 59 | #endif |
| 60 | |
| 61 | /***************************************************************************/ |
| 62 | /* Shared functions */ |
| 63 | |
| 64 | int32_tcxx . . $ int32_t# mz_path_combinecxx . . $ mz_path_combine(c42ad7cb79e2bab7).(char *path, const char *join, int32_tcxx . . $ int32_t# max_path); |
| 65 | /* Combines two paths */ |
| 66 | |
| 67 | int32_tcxx . . $ int32_t# mz_path_append_slashcxx . . $ mz_path_append_slash(7799835858448083).(char *path, int32_tcxx . . $ int32_t# max_path, char slash); |
| 68 | /* Appends a path slash on to the end of the path */ |
| 69 | |
| 70 | int32_tcxx . . $ int32_t# mz_path_remove_slashcxx . . $ mz_path_remove_slash(1ef8e6ec083aabb9).(char *path); |
| 71 | /* Removes a path slash from the end of the path */ |
| 72 | |
| 73 | int32_tcxx . . $ int32_t# mz_path_has_slashcxx . . $ mz_path_has_slash(5c4306d8553b3696).(const char *path); |
| 74 | /* Returns whether or not the path ends with slash */ |
| 75 | |
| 76 | int32_tcxx . . $ int32_t# mz_path_convert_slashescxx . . $ mz_path_convert_slashes(aaa73ea12dc6a7b7).(char *path, char slash); |
| 77 | /* Converts the slashes in a path */ |
| 78 | |
| 79 | int32_tcxx . . $ int32_t# mz_path_compare_wccxx . . $ mz_path_compare_wc(6dbe66b8d729cbab).(const char *path, const char *wildcard, uint8_tcxx . . $ uint8_t# ignore_case); |
| 80 | /* Compare two paths with wildcard */ |
| 81 | |
| 82 | int32_tcxx . . $ int32_t# mz_path_resolvecxx . . $ mz_path_resolve(89c8e27db0bdb94e).(const char *path, char *target, int32_tcxx . . $ int32_t# max_target); |
| 83 | /* Resolves path */ |
| 84 | |
| 85 | int32_tcxx . . $ int32_t# mz_path_remove_filenamecxx . . $ mz_path_remove_filename(1ef8e6ec083aabb9).(char *path); |
| 86 | /* Remove the filename from a path */ |
| 87 | |
| 88 | int32_tcxx . . $ int32_t# mz_path_remove_extensioncxx . . $ mz_path_remove_extension(1ef8e6ec083aabb9).(char *path); |
| 89 | /* Remove the extension from a path */ |
| 90 | |
| 91 | int32_tcxx . . $ int32_t# mz_path_get_filenamecxx . . $ mz_path_get_filename(2ef3bc9ee8f8b3e9).(const char *path, const char **filename); |
| 92 | /* Get the filename from a path */ |
| 93 | |
| 94 | int32_tcxx . . $ int32_t# mz_dir_makecxx . . $ mz_dir_make(5c4306d8553b3696).(const char *path); |
| 95 | /* Creates a directory recursively */ |
| 96 | |
| 97 | int32_tcxx . . $ int32_t# mz_file_get_crccxx . . $ mz_file_get_crc(6974107818eeb505).(const char *path, uint32_tcxx . . $ uint32_t# *result_crc); |
| 98 | /* Gets the crc32 hash of a file */ |
| 99 | |
| 100 | /***************************************************************************/ |
| 101 | /* Platform specific functions */ |
| 102 | |
| 103 | wchar_t *mz_os_unicode_string_createcxx . . $ mz_os_unicode_string_create(74357ab27f849a64).(const char *string, int32_tcxx . . $ int32_t# encoding); |
| 104 | /* Create unicode string from a utf8 string */ |
| 105 | |
| 106 | void mz_os_unicode_string_deletecxx . . $ mz_os_unicode_string_delete(a356f1ff64b2b525).(wchar_t **string); |
| 107 | /* Delete a unicode string that was created */ |
| 108 | |
| 109 | char *mz_os_utf8_string_createcxx . . $ mz_os_utf8_string_create(2050848944e00d54).(const char *string, int32_tcxx . . $ int32_t# encoding); |
| 110 | /* Create a utf8 string from a string with another encoding */ |
| 111 | |
| 112 | void mz_os_utf8_string_deletecxx . . $ mz_os_utf8_string_delete(3ed91490e421178f).(char **string); |
| 113 | /* Delete a utf8 string that was created */ |
| 114 | |
| 115 | int32_tcxx . . $ int32_t# mz_os_randcxx . . $ mz_os_rand(7405b416d0535413).(uint8_tcxx . . $ uint8_t# *buf, int32_tcxx . . $ int32_t# size); |
| 116 | /* Random number generator (not cryptographically secure) */ |
| 117 | |
| 118 | int32_tcxx . . $ int32_t# mz_os_renamecxx . . $ mz_os_rename(5ae29d726ae57f88).(const char *source_path, const char *target_path); |
| 119 | /* Rename a file */ |
| 120 | |
| 121 | int32_tcxx . . $ int32_t# mz_os_unlinkcxx . . $ mz_os_unlink(5c4306d8553b3696).(const char *path); |
| 122 | /* Delete an existing file */ |
| 123 | |
| 124 | int32_tcxx . . $ int32_t# mz_os_file_existscxx . . $ mz_os_file_exists(5c4306d8553b3696).(const char *path); |
| 125 | /* Check to see if a file exists */ |
| 126 | |
| 127 | int64_tcxx . . $ int64_t# mz_os_get_file_sizecxx . . $ mz_os_get_file_size(3c95bd14d5d5d286).(const char *path); |
| 128 | /* Gets the length of a file */ |
| 129 | |
| 130 | int32_tcxx . . $ int32_t# mz_os_get_file_datecxx . . $ mz_os_get_file_date(d6a2abb5a2f53069).(const char *path, time_tcxx . . $ time_t# *modified_date, time_tcxx . . $ time_t# *accessed_date, time_tcxx . . $ time_t# *creation_date); |
| 131 | /* Gets a file's modified, access, and creation dates if supported */ |
| 132 | |
| 133 | int32_tcxx . . $ int32_t# mz_os_set_file_datecxx . . $ mz_os_set_file_date(3744568063355712).(const char *path, time_tcxx . . $ time_t# modified_date, time_tcxx . . $ time_t# accessed_date, time_tcxx . . $ time_t# creation_date); |
| 134 | /* Sets a file's modified, access, and creation dates if supported */ |
| 135 | |
| 136 | int32_tcxx . . $ int32_t# mz_os_get_file_attribscxx . . $ mz_os_get_file_attribs(6974107818eeb505).(const char *path, uint32_tcxx . . $ uint32_t# *attributes); |
| 137 | /* Gets a file's attributes */ |
| 138 | |
| 139 | int32_tcxx . . $ int32_t# mz_os_set_file_attribscxx . . $ mz_os_set_file_attribs(1df18506ef0a631b).(const char *path, uint32_tcxx . . $ uint32_t# attributes); |
| 140 | /* Sets a file's attributes */ |
| 141 | |
| 142 | int32_tcxx . . $ int32_t# mz_os_make_dircxx . . $ mz_os_make_dir(5c4306d8553b3696).(const char *path); |
| 143 | /* Recursively creates a directory */ |
| 144 | |
| 145 | DIRcxx . . $ DIR# *mz_os_open_dircxx . . $ mz_os_open_dir(f465d4b65cec8dd2).(const char *path); |
| 146 | /* Opens a directory for listing */ |
| 147 | struct direntcxx . . $ dirent# *mz_os_read_dircxx . . $ mz_os_read_dir(ffbaae344e1a615a).(DIRcxx . . $ DIR# *dir); |
| 148 | /* Reads a directory listing entry */ |
| 149 | |
| 150 | int32_tcxx . . $ int32_t# mz_os_close_dircxx . . $ mz_os_close_dir(ac30a447bc7c2f80).(DIRcxx . . $ DIR# *dir); |
| 151 | /* Closes a directory that has been opened for listing */ |
| 152 | |
| 153 | int32_tcxx . . $ int32_t# mz_os_is_dir_separatorcxx . . $ mz_os_is_dir_separator(784f3405e7e545be).(const char c); |
| 154 | /* Checks to see if character is a directory separator */ |
| 155 | |
| 156 | int32_tcxx . . $ int32_t# mz_os_is_dircxx . . $ mz_os_is_dir(5c4306d8553b3696).(const char *path); |
| 157 | /* Checks to see if path is a directory */ |
| 158 | |
| 159 | int32_tcxx . . $ int32_t# mz_os_is_symlinkcxx . . $ mz_os_is_symlink(5c4306d8553b3696).(const char *path); |
| 160 | /* Checks to see if path is a symbolic link */ |
| 161 | |
| 162 | int32_tcxx . . $ int32_t# mz_os_make_symlinkcxx . . $ mz_os_make_symlink(5ae29d726ae57f88).(const char *path, const char *target_path); |
| 163 | /* Creates a symbolic link pointing to a target */ |
| 164 | |
| 165 | int32_tcxx . . $ int32_t# mz_os_read_symlinkcxx . . $ mz_os_read_symlink(89c8e27db0bdb94e).(const char *path, char *target_path, int32_tcxx . . $ int32_t# max_target_path); |
| 166 | /* Gets the target path for a symbolic link */ |
| 167 | |
| 168 | uint64_tcxx . . $ uint64_t# mz_os_ms_timecxx . . $ mz_os_ms_time(f708dce9a8856c70).(void); |
| 169 | /* Gets the time in milliseconds */ |
| 170 | |
| 171 | /***************************************************************************/ |
| 172 | |
| 173 | #ifdef __cplusplus |
| 174 | } |
| 175 | #endif |
| 176 | |
| 177 | #endif |