@@ -121,8 +121,8 @@ void s3dat_write_packed(s3dat_t* handle, s3dat_res_t* res, uint32_t* pos, uint32
121
121
s3dat_unref (res -> res );
122
122
}
123
123
124
- void s3dat_internal_export_seq_index (s3dat_t * handle , s3dat_seq_index_t * index , uint32_t * seq_pos , uint32_t pos , uint32_t * append_pos , s3util_exception_t * * throws ) {
125
- s3dat_res_t res = {0 , 0 , index -> type , NULL };
124
+ void s3dat_internal_export_seq_index (s3dat_t * handle , s3dat_seq_index_t * index , s3dat_content_type type , uint32_t * seq_pos , uint32_t pos , uint32_t * append_pos , s3util_exception_t * * throws ) {
125
+ s3dat_res_t res = {0 , 0 , type , NULL };
126
126
127
127
for (uint16_t s = 0 ;s != index -> len ;s ++ ) {
128
128
res .first_index = s ;
@@ -144,10 +144,10 @@ void s3dat_internal_export_seq_index(s3dat_t* handle, s3dat_seq_index_t* index,
144
144
}
145
145
}
146
146
147
- void s3dat_internal_export_index (s3dat_t * handle , s3dat_index_t * index , uint32_t pos , uint32_t * append_pos , s3util_exception_t * * throws ) {
147
+ void s3dat_internal_export_index (s3dat_t * handle , s3dat_index_t * index , s3dat_content_type type , uint32_t pos , uint32_t * append_pos , s3util_exception_t * * throws ) {
148
148
uint32_t data_positions [index -> len ];
149
149
150
- s3dat_res_t res = {0 , 0 , index -> type , NULL };
150
+ s3dat_res_t res = {0 , 0 , type , NULL };
151
151
152
152
for (uint16_t i = 0 ;i != index -> len ;i ++ ) {
153
153
res .first_index = i ;
@@ -156,13 +156,50 @@ void s3dat_internal_export_index(s3dat_t* handle, s3dat_index_t* index, uint32_t
156
156
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
157
157
}
158
158
159
- s3dat_internal_write_index (handle , pos , index -> type , index -> len , data_positions , throws );
159
+ s3dat_internal_write_index (handle , pos , type , index -> len , data_positions , throws );
160
160
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
161
161
162
162
s3dat_internal_seek_func (handle , * append_pos , S3UTIL_SEEK_SET , throws );
163
163
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
164
164
}
165
165
166
+ void s3dat_writefile_name (s3dat_t * handle , char * name , s3util_exception_t * * throws ) {
167
+ s3dat_init_name (handle , name );
168
+ s3dat_writefile (handle , throws );
169
+ S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
170
+ }
171
+
172
+ void s3dat_writefile_fd (s3dat_t * handle , uint32_t * file , s3util_exception_t * * throws ) {
173
+ s3dat_init_fd (handle , file );
174
+ s3dat_writefile (handle , throws );
175
+ S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
176
+ }
177
+
178
+ void s3dat_writefile_func (s3dat_t * handle , void * arg ,
179
+ bool (* read_func ) (void * , void * , size_t ),
180
+ bool (* write_func ) (void * , void * , size_t ),
181
+ size_t (* size_func ) (void * ),
182
+ size_t (* pos_func ) (void * ),
183
+ bool (* seek_func ) (void * , uint32_t , int ),
184
+ void * (* open_func ) (void * , bool ),
185
+ void (* close_func ) (void * ),
186
+ void * (* fork_func ) (void * ),
187
+ s3util_exception_t * * throws ) {
188
+ s3dat_init_func (handle , arg , read_func , write_func , size_func , pos_func , seek_func , open_func , close_func , fork_func );
189
+ s3dat_writefile (handle , throws );
190
+ S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
191
+ }
192
+
193
+ void s3dat_writefile_ioset (s3dat_t * handle , void * io_arg , s3util_ioset_t * ioset , bool use_openclose_func , s3util_exception_t * * throws ) {
194
+ if (!s3dat_init_ioset (handle , io_arg , ioset , use_openclose_func )) {
195
+ s3util_throw (s3dat_memset (handle ), throws , S3UTIL_EXCEPTION_IOSET , __FILE__ , __func__ , __LINE__ );
196
+ return ;
197
+ }
198
+
199
+ s3dat_writefile (handle , throws );
200
+ S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
201
+ }
202
+
166
203
void s3dat_writefile (s3dat_t * handle , s3util_exception_t * * throws ) {
167
204
if (s3dat_ioset (handle )-> open_func != NULL ) s3dat_ioset (handle )-> arg = s3dat_ioset (handle )-> open_func (s3dat_ioset (handle )-> arg , true);
168
205
@@ -249,25 +286,25 @@ void s3dat_writefile(s3dat_t* handle, s3util_exception_t** throws) {
249
286
s3dat_internal_seek_func (handle , append_pos , S3UTIL_SEEK_SET , throws );
250
287
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
251
288
252
- s3dat_internal_export_index (handle , handle -> landscape_index , landscape_pos , & append_pos , throws );
289
+ s3dat_internal_export_index (handle , handle -> landscape_index , s3dat_landscape , landscape_pos , & append_pos , throws );
253
290
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
254
291
255
- s3dat_internal_export_index (handle , handle -> gui_index , gui_pos , & append_pos , throws );
292
+ s3dat_internal_export_index (handle , handle -> gui_index , s3dat_gui , gui_pos , & append_pos , throws );
256
293
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
257
294
258
- s3dat_internal_export_seq_index (handle , handle -> settler_index , settler_seq_pos , settler_pos , & append_pos , throws );
295
+ s3dat_internal_export_seq_index (handle , handle -> settler_index , s3dat_settler , settler_seq_pos , settler_pos , & append_pos , throws );
259
296
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
260
297
261
- s3dat_internal_export_seq_index (handle , handle -> torso_index , torso_seq_pos , torso_pos , & append_pos , throws );
298
+ s3dat_internal_export_seq_index (handle , handle -> torso_index , s3dat_torso , torso_seq_pos , torso_pos , & append_pos , throws );
262
299
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
263
300
264
- s3dat_internal_export_seq_index (handle , handle -> shadow_index , shadow_seq_pos , shadow_pos , & append_pos , throws );
301
+ s3dat_internal_export_seq_index (handle , handle -> shadow_index , s3dat_shadow , shadow_seq_pos , shadow_pos , & append_pos , throws );
265
302
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
266
303
267
- s3dat_internal_export_index (handle , handle -> animation_index , animation_pos , & append_pos , throws );
304
+ s3dat_internal_export_index (handle , handle -> animation_index , s3dat_animation , animation_pos , & append_pos , throws );
268
305
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
269
306
270
- s3dat_internal_export_index (handle , handle -> palette_index , palette_pos , & append_pos , throws );
307
+ s3dat_internal_export_index (handle , handle -> palette_index , s3dat_palette , palette_pos , & append_pos , throws );
271
308
S3UTIL_HANDLE_EXCEPTION (s3dat_memset (handle ), throws , __FILE__ , __func__ , __LINE__ );
272
309
273
310
s3dat_internal_seek_func (handle , 48 , S3UTIL_SEEK_SET , throws );
0 commit comments