comparison tools/packed.c @ 1108:5a8d29b88431

More fixes.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Mar 2015 00:50:53 +0200
parents d0f80f6a0c65
children c1583a2278ec
comparison
equal deleted inserted replaced
1107:69c0d8ad2672 1108:5a8d29b88431
209 hdr.dirOffset += node->length; 209 hdr.dirOffset += node->length;
210 node = node->next; 210 node = node->next;
211 } 211 }
212 212
213 // Write PACK header 213 // Write PACK header
214 if (DM_FSEEK64(pack->file, 0, SEEK_SET) != 0) 214 if (fseeko(pack->file, 0, SEEK_SET) != 0)
215 return DMERR_FSEEK; 215 return DMERR_FSEEK;
216 216
217 if (!dm_fwrite_str(pack->file, (Uint8 *) & hdr.ident, sizeof(hdr.ident)) || 217 if (!dm_fwrite_str(pack->file, (Uint8 *) & hdr.ident, sizeof(hdr.ident)) ||
218 !dm_fwrite_le16(pack->file, hdr.version) || 218 !dm_fwrite_le16(pack->file, hdr.version) ||
219 !dm_fwrite_le32(pack->file, hdr.dirEntries) || 219 !dm_fwrite_le32(pack->file, hdr.dirEntries) ||
220 !dm_fwrite_le64(pack->file, hdr.dirOffset)) 220 !dm_fwrite_le64(pack->file, hdr.dirOffset))
221 return DMERR_FWRITE; 221 return DMERR_FWRITE;
222 222
223 // Write the directory 223 // Write the directory
224 if (DM_FSEEK64(pack->file, hdr.dirOffset, SEEK_SET) != 0) 224 if (fseeko(pack->file, hdr.dirOffset, SEEK_SET) != 0)
225 return DMERR_FSEEK; 225 return DMERR_FSEEK;
226 226
227 node = pack->entries; 227 node = pack->entries;
228 while (node != NULL) 228 while (node != NULL)
229 { 229 {
293 startOffs += node->length; 293 startOffs += node->length;
294 node = node->next; 294 node = node->next;
295 } 295 }
296 296
297 // Seek to the position 297 // Seek to the position
298 if (DM_FSEEK64(pack->file, startOffs, SEEK_SET) != 0) 298 if (fseeko(pack->file, startOffs, SEEK_SET) != 0)
299 return DMERR_INVALID; 299 return DMERR_INVALID;
300 300
301 // Read file data 301 // Read file data
302 if ((inFile = fopen(filename, "rb")) == NULL) 302 if ((inFile = fopen(filename, "rb")) == NULL)
303 return DMERR_FOPEN; 303 return DMERR_FOPEN;
411 411
412 if (pack->file == NULL) 412 if (pack->file == NULL)
413 return DMERR_FOPEN; 413 return DMERR_FOPEN;
414 414
415 // Seek to the position 415 // Seek to the position
416 if (DM_FSEEK64(pack->file, entry->offset, SEEK_SET) != 0) 416 if (fseeko(pack->file, entry->offset, SEEK_SET) != 0)
417 return DMERR_FSEEK; 417 return DMERR_FSEEK;
418 418
419 // Open destination file 419 // Open destination file
420 if ((outFile = fopen(entry->filename, "wb")) == NULL) 420 if ((outFile = fopen(entry->filename, "wb")) == NULL)
421 return DMERR_FOPEN; 421 return DMERR_FOPEN;