GPAK  1.0.0
A general-purpose archive library

◆ _gpak_decompressor_none()

GPAK_API uint32_t _gpak_decompressor_none ( gpak_t _pak,
FILE *  _infile,
FILE *  _outfile,
size_t  _read_size 
)
Brief Description:\n Performs no decompression on the input file.

This function reads data from the input file and writes it directly to the output file without any decompression.

Parameters
_pakA pointer to the gpak_t.
_infileA pointer to the input FILE.
_outfileA pointer to the output FILE.
_read_sizeThe number of bytes to read from the input file.
Returns
The number of bytes written to the output file.

Definition at line 67 of file gpak_compressors.c.

68 {
69  char* _bufferIn = (char*)malloc(_DEFAULT_BLOCK_SIZE);
70  size_t bytesReaded = 0ull;
71  size_t nextBlockSize = _DEFAULT_BLOCK_SIZE;
72 
73  uint32_t _crc32 = crc32(0L, Z_NULL, 0);
74 
75  do
76  {
77  size_t _readed = _freadb(_bufferIn, 1ull, nextBlockSize, _infile);
78  _crc32 = crc32(_crc32, _bufferIn, _readed);
79 
80  _fwriteb(_bufferIn, 1ull, _readed, _outfile);
81  bytesReaded += _readed;
82  _gpak_pass_progress(_pak, bytesReaded, _read_size, GPAK_STAGE_DECOMPRESSION);
83 
84  if (_read_size - bytesReaded < nextBlockSize)
85  nextBlockSize = _read_size - bytesReaded;
86  } while (bytesReaded != _read_size);
87 
88  if (bytesReaded != _read_size)
89  return _gpak_make_error(_pak, GPAK_ERROR_READ);
90 
91  free(_bufferIn);
92 
93  return _crc32;
94 }
@ GPAK_ERROR_READ
Definition: gpak_data.h:162
@ GPAK_STAGE_DECOMPRESSION
Definition: gpak_data.h:227

Referenced by gpak_fopen().