< index
< 11. Compression toolkit
< 11.2 Putting data in the buffer

=====================================
11.3 Saving the compressed data to a file
=====================================

> 11.4 Loading compressed data from a file
Once you have finished adding data in the buffer, you can compress it and save it in a file.

C++ : int TCODZip::saveToFile(const char *filename)
C   : int TCOD_zip_save_to_file(TCOD_zip_t zip, const char *filename)


ParameterDescription
zipIn the C version, the buffer handler, returned by the constructor.
filenameName of the file
The function returns the number of (uncompressed) bytes saved.
Example :

C++ : TCODZip zip;
      zip.putChar('A');
      zip.putInt(1764);
      zip.putFloat(3.14f);
      zip.putString("A string");
      zip.putData(nbBytes, dataPtr);
      zip.saveToFile("myCompressedFile.gz");
C   : TCOD_zip_t zip=TCOD_zip_new();
      TCOD_zip_put_char(zip,'A');
      TCOD_zip_put_int(zip,1764);
      TCOD_zip_put_float(zip,3.14f);
      TCOD_zip_put_string(zip,"A string");
      TCOD_zip_put_data(zip,nbBytes, dataPtr);
      TCOD_zip_save_to_file(zip,"myCompressedFile.gz");

insert a comment