Mercurial > hg > dmlib
comparison src/dmres.c @ 1010:ffd1ca99e456
Rename label.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 01 Mar 2015 03:58:05 +0200 |
parents | aeafd6d44465 |
children | 501ee5f0c043 |
comparison
equal
deleted
inserted
replaced
1009:6c409806871f | 1010:ffd1ca99e456 |
---|---|
406 int ret; | 406 int ret; |
407 | 407 |
408 if ((inBuf = dmMalloc(node->length)) == NULL) | 408 if ((inBuf = dmMalloc(node->length)) == NULL) |
409 { | 409 { |
410 ret = DMERR_MALLOC; | 410 ret = DMERR_MALLOC; |
411 goto err; | 411 goto out; |
412 } | 412 } |
413 | 413 |
414 if (fread(inBuf, sizeof(Uint8), node->length, handle->lib->packFile->file) != node->length) | 414 if (fread(inBuf, sizeof(Uint8), node->length, handle->lib->packFile->file) != node->length) |
415 { | 415 { |
416 ret = DMERR_FREAD; | 416 ret = DMERR_FREAD; |
417 goto err; | 417 goto out; |
418 } | 418 } |
419 | 419 |
420 if ((ctx.zout = ctx.zoutStart = dmMalloc(node->size)) == NULL) | 420 if ((ctx.zout = ctx.zoutStart = dmMalloc(node->size)) == NULL) |
421 { | 421 { |
422 ret = dmError(DMERR_MALLOC, | 422 ret = dmError(DMERR_MALLOC, |
423 "Failed to allocate initial decompression buffer.\n"); | 423 "Failed to allocate initial decompression buffer.\n"); |
424 goto err; | 424 goto out; |
425 } | 425 } |
426 | 426 |
427 ctx.zbuffer = inBuf; | 427 ctx.zbuffer = inBuf; |
428 ctx.zbufferEnd = inBuf + node->length; | 428 ctx.zbufferEnd = inBuf + node->length; |
429 ctx.zoutEnd = ctx.zoutStart + node->size; | 429 ctx.zoutEnd = ctx.zoutStart + node->size; |
430 ctx.expandable = TRUE; | 430 ctx.expandable = TRUE; |
431 | 431 |
432 if ((ret = dmZLibParseHeader(&ctx, TRUE)) != DMERR_OK) | 432 if ((ret = dmZLibParseHeader(&ctx, TRUE)) != DMERR_OK) |
433 goto err; | 433 goto out; |
434 | 434 |
435 if ((ret = dmZLibDecode(&ctx)) != DMERR_OK) | 435 if ((ret = dmZLibDecode(&ctx)) != DMERR_OK) |
436 goto err; | 436 goto out; |
437 | 437 |
438 handle->rawOffset = 0; | 438 handle->rawOffset = 0; |
439 handle->rawData = ctx.zoutStart; | 439 handle->rawData = ctx.zoutStart; |
440 handle->rawSize = ctx.zout - ctx.zoutStart; | 440 handle->rawSize = ctx.zout - ctx.zoutStart; |
441 if (handle->rawSize != node->size) | 441 if (handle->rawSize != node->size) |
465 if ((node = dmPackFind(handle->lib->packFile->entries, handle->filename)) == NULL) | 465 if ((node = dmPackFind(handle->lib->packFile->entries, handle->filename)) == NULL) |
466 { | 466 { |
467 res = dmError(DMERR_NOT_FOUND, | 467 res = dmError(DMERR_NOT_FOUND, |
468 "Entry '%s' not found in PACK file.\n", | 468 "Entry '%s' not found in PACK file.\n", |
469 handle->filename); | 469 handle->filename); |
470 goto error; | 470 goto out; |
471 } | 471 } |
472 | 472 |
473 // Seek to entry | 473 // Seek to entry |
474 if (fseek(handle->lib->packFile->file, node->offset, SEEK_SET) == -1) | 474 if (fseek(handle->lib->packFile->file, node->offset, SEEK_SET) == -1) |
475 { | 475 { |
476 res = dmError(DMERR_FSEEK, | 476 res = dmError(DMERR_FSEEK, |
477 "Could not seek node position in PACK file.\n"); | 477 "Could not seek node position in PACK file.\n"); |
478 goto error; | 478 goto out; |
479 } | 479 } |
480 | 480 |
481 res = dm_pack_decompress(handle, node); | 481 res = dm_pack_decompress(handle, node); |
482 | 482 |
483 error: | 483 out: |
484 return res; | 484 return res; |
485 } | 485 } |
486 | 486 |
487 | 487 |
488 static int dm_pack_fopen(DMResource * f) | 488 static int dm_pack_fopen(DMResource * f) |