Mercurial > hg > dmlib
comparison tools/packed.c @ 1036:1a0a327d8fed
Use 64bit file offsets.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 01 Mar 2015 16:57:50 +0200 |
parents | d2fa4f6d6117 |
children | d674ddc0fc82 |
comparison
equal
deleted
inserted
replaced
1035:d2fa4f6d6117 | 1036:1a0a327d8fed |
---|---|
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 (fseek(pack->file, 0L, SEEK_SET) != 0) | 214 if (DM_FSEEK64(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_le32(pack->file, hdr.dirOffset)) | 220 !dm_fwrite_le32(pack->file, hdr.dirOffset)) |
221 return DMERR_FWRITE; | 221 return DMERR_FWRITE; |
222 | 222 |
223 // Write the directory | 223 // Write the directory |
224 if (fseek(pack->file, hdr.dirOffset, SEEK_SET) != 0) | 224 if (DM_FSEEK64(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 { |
292 startOffs += node->length; | 292 startOffs += node->length; |
293 node = node->next; | 293 node = node->next; |
294 } | 294 } |
295 | 295 |
296 // Seek to the position | 296 // Seek to the position |
297 if (fseek(pack->file, startOffs, SEEK_SET) != 0) | 297 if (DM_FSEEK64(pack->file, startOffs, SEEK_SET) != 0) |
298 return DMERR_INVALID; | 298 return DMERR_INVALID; |
299 | 299 |
300 // Read file data | 300 // Read file data |
301 if ((inFile = fopen(filename, "rb")) == NULL) | 301 if ((inFile = fopen(filename, "rb")) == NULL) |
302 return DMERR_FOPEN; | 302 return DMERR_FOPEN; |
409 | 409 |
410 if (pack->file == NULL) | 410 if (pack->file == NULL) |
411 return DMERR_FOPEN; | 411 return DMERR_FOPEN; |
412 | 412 |
413 // Seek to the position | 413 // Seek to the position |
414 if (fseek(pack->file, entry->offset, SEEK_SET) != 0) | 414 if (DM_FSEEK64(pack->file, entry->offset, SEEK_SET) != 0) |
415 return DMERR_FSEEK; | 415 return DMERR_FSEEK; |
416 | 416 |
417 // Open destination file | 417 // Open destination file |
418 if ((outFile = fopen(entry->filename, "wb")) == NULL) | 418 if ((outFile = fopen(entry->filename, "wb")) == NULL) |
419 return DMERR_FOPEN; | 419 return DMERR_FOPEN; |