RetroArch
archive_file.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2018 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (archive_file.h).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef LIBRETRO_SDK_ARCHIVE_FILE_H__
24 #define LIBRETRO_SDK_ARCHIVE_FILE_H__
25 
26 #include <stdint.h>
27 #include <stddef.h>
28 #include <boolean.h>
29 
30 #ifdef _WIN32
31 #include <direct.h>
32 #else
33 #include <unistd.h>
34 #endif
35 
36 #include <retro_miscellaneous.h>
37 
38 #include <retro_common_api.h>
39 
41 
43 
45 {
51 };
52 
53 typedef struct file_archive_handle
54 {
55  void *stream;
60 
62 
63 typedef struct file_archive_transfer
64 {
68  void *stream;
69  const uint8_t *footer;
71  const uint8_t *data;
74 
76 {
79 };
80 
82 {
83  char *opt_file;
84  char *needle;
85  void **buf;
86  size_t size;
87  bool found;
88 };
89 
90 typedef struct
91 {
92  char *source_file;
93  char *subdir;
94  char *target_dir;
95  char *target_file;
96  char *valid_ext;
97 
99 
103 
105 {
109  const char *extraction_directory;
111  struct string_list *ext;
112  struct string_list *list;
114  bool list_only;
115  void *context;
120 };
121 
122 /* Returns true when parsing should continue. False to stop. */
123 typedef int (*file_archive_file_cb)(const char *name, const char *valid_exts,
124  const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
125  uint32_t crc32, struct archive_extract_userdata *userdata);
126 
128 {
129  void *(*stream_new)(void);
130  void (*stream_free)(void *);
135  int (*compressed_file_read)(const char *path, const char *needle, void **buf,
136  const char *optional_outfile);
139  const char *file);
142  const char *valid_exts,
143  struct archive_extract_userdata *userdata,
144  file_archive_file_cb file_cb);
145  const char *ident;
146 };
147 
150  bool *returnerr,
151  const char *file,
152  const char *valid_exts,
153  file_archive_file_cb file_cb,
154  struct archive_extract_userdata *userdata);
155 
157 
159 
174  const char *valid_exts, const char *extraction_dir,
175  char *out_path, size_t len);
176 
185 struct string_list* file_archive_get_file_list(const char *path, const char *valid_exts);
186 
187 bool file_archive_perform_mode(const char *name, const char *valid_exts,
188  const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
189  uint32_t crc32, struct archive_extract_userdata *userdata);
190 
192  const char* path, void **buf,
193  const char* optional_filename, int64_t *length);
194 
197 
199 
209 
210 extern const struct file_archive_file_backend zlib_backend;
211 extern const struct file_archive_file_backend sevenzip_backend;
212 
214 
215 #endif
216 
uint32_t real_checksum
Definition: archive_file.h:57
uint8_t * data
Definition: archive_file.h:56
GLuint const GLchar * name
Definition: glext.h:6671
int file_archive_parse_file_progress(file_archive_transfer_t *state)
Definition: archive_file.c:498
int(* archive_parse_file_init)(file_archive_transfer_t *state, const char *file)
Definition: archive_file.h:137
char * extracted_file_path
Definition: archive_file.h:108
char * subdir
Definition: archive_file.h:93
void * stream
Definition: archive_file.h:68
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
bool found
Definition: archive_file.h:87
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
Definition: archive_file.h:53
const struct file_archive_file_backend zlib_backend
Definition: archive_file_zlib.c:374
GLsizei const GLchar ** path
Definition: glext.h:7901
char * target_dir
Definition: archive_file.h:94
void file_archive_parse_file_iterate_stop(file_archive_transfer_t *state)
Definition: archive_file.c:370
GLenum GLsizei len
Definition: glext.h:7389
GLsizeiptr size
Definition: glext.h:6559
int32_t archive_size
Definition: archive_file.h:66
Definition: archive_file.h:47
int file_archive_parse_file_iterate(file_archive_transfer_t *state, bool *returnerr, const char *file, const char *valid_exts, file_archive_file_cb file_cb, struct archive_extract_userdata *userdata)
Definition: archive_file.c:379
Definition: archive_file.c:49
Definition: archive_file.h:127
Definition: archive_file.h:78
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
char archive_name[PATH_MAX_LENGTH]
Definition: archive_file.h:116
bool file_archive_extract_file(char *archive_path, size_t archive_path_size, const char *valid_exts, const char *extraction_dir, char *out_path, size_t len)
Definition: archive_file.c:524
Definition: archive_file.h:49
#define PATH_MAX_LENGTH
Definition: retro_miscellaneous.h:83
const char * ident
Definition: archive_file.h:145
typedef bool(RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index
const struct file_archive_file_backend * backend
Definition: archive_file.h:72
struct string_list * list
Definition: archive_file.h:112
const uint8_t * data
Definition: archive_file.h:71
struct file_archive_transfer file_archive_transfer_t
Definition: archive_file.h:81
void ** buf
Definition: archive_file.h:85
char * needle
Definition: archive_file.h:84
bool list_only
Definition: archive_file.h:114
char archive_path[PATH_MAX_LENGTH]
Definition: archive_file.h:106
const struct file_archive_file_backend * backend
Definition: archive_file.h:58
int file_archive_compressed_read(const char *path, void **buf, const char *optional_filename, int64_t *length)
Definition: archive_file.c:734
const uint8_t * footer
Definition: archive_file.h:69
struct string_list * file_archive_get_file_list(const char *path, const char *valid_exts)
Definition: archive_file.c:593
bool file_archive_perform_mode(const char *name, const char *valid_exts, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, uint32_t crc32, struct archive_extract_userdata *userdata)
Definition: archive_file.c:638
void(* stream_free)(void *)
Definition: archive_file.h:130
const char * extraction_directory
Definition: archive_file.h:109
static uint64_t state[MAX_PADS]
Definition: xenon360_input.c:33
Definition: archive_file.h:104
Definition: archive_file.h:63
struct file_archive_handle file_archive_file_handle_t
file_archive_file_data_t * handle
Definition: archive_file.h:67
const struct file_archive_file_backend * file_archive_get_zlib_file_backend(void)
Definition: archive_file.c:782
signed int int32_t
Definition: stdint.h:123
const uint8_t * directory
Definition: archive_file.h:70
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
char * callback_error
Definition: archive_file.h:98
void * context
Definition: archive_file.h:115
uint32_t(* stream_crc_calculate)(uint32_t, const uint8_t *, size_t)
Definition: archive_file.h:134
char * target_file
Definition: archive_file.h:95
file_archive_transfer_type
Definition: archive_file.h:44
Definition: archive_file.h:46
int(* archive_parse_file_iterate_step)(file_archive_transfer_t *state, const char *valid_exts, struct archive_extract_userdata *userdata, file_archive_file_cb file_cb)
Definition: archive_file.h:140
Definition: archive_file.h:77
Definition: archive_file.h:90
struct archive_extract_userdata * userdata
Definition: archive_file.h:101
enum file_archive_transfer_type type
Definition: archive_file.h:65
struct string_list * ext
Definition: archive_file.h:111
size_t archive_path_size
Definition: archive_file.h:110
uint32_t crc
Definition: archive_file.h:117
bool(* stream_decompress_data_to_file_init)(file_archive_file_handle_t *, const uint8_t *, uint32_t, uint32_t)
Definition: archive_file.h:131
size_t size
Definition: archive_file.h:86
const struct file_archive_file_backend * file_archive_get_7z_file_backend(void)
Definition: archive_file.c:791
void * stream
Definition: archive_file.h:55
file_archive_transfer_t archive
Definition: archive_file.h:100
signed __int64 int64_t
Definition: stdint.h:135
decompress_state_t * dec
Definition: archive_file.h:119
unsigned long crc32(unsigned long crc, const unsigned char *buf, unsigned int len)
Definition: libz-crc32.c:70
int(* stream_decompress_data_to_file_iterate)(void *)
Definition: archive_file.h:133
uint32_t file_archive_get_file_crc32(const char *path)
Definition: archive_file.c:840
Definition: archive_file.h:48
file_archive_compression_mode
Definition: archive_file.h:75
Definition: archive_file.h:50
bool found_file
Definition: archive_file.h:113
const struct file_archive_file_backend * file_archive_get_file_backend(const char *path)
Definition: archive_file.c:800
char * first_extracted_file_path
Definition: archive_file.h:107
char * valid_ext
Definition: archive_file.h:96
Definition: civetweb.c:1024
int(* file_archive_file_cb)(const char *name, const char *valid_exts, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, uint32_t crc32, struct archive_extract_userdata *userdata)
Definition: archive_file.h:123
char * opt_file
Definition: archive_file.h:83
GLenum GLuint GLenum GLsizei length
Definition: glext.h:6233
char * source_file
Definition: archive_file.h:92
unsigned char uint8_t
Definition: stdint.h:124
unsigned int uint32_t
Definition: stdint.h:126
const struct file_archive_file_backend sevenzip_backend
Definition: archive_file_7z.c:506
struct decomp_state_t decomp_state
Definition: archive_file.h:118
int(* compressed_file_read)(const char *path, const char *needle, void **buf, const char *optional_outfile)
Definition: archive_file.h:135
Definition: string_list.h:47