How to compress a .json file into .json.gz file format in c++? - gzip

I compressed a json string in gzipped format.
But I want to compress a .json file into .json.gz file format.
How can I do that in c++?

I could compress a file into .gz file in cpp that I needed.
Used linux terminal command for file gzip
char Command[] = "gzip filepath/filename.json";
Then executed the command in code by using
int sysRet = system(Command);
Then in device storage desired filepath filename.json.gz file will be created.

Related

How to compress folders into ext4 in Windows?

I wanted to compress a file into an img file in ext4 format, but I couldn't find the corresponding tool under Windows.

Open a gz file using Minizip Library

I'm trying to open a gz file with Minizip library (built on zlib).
Here is the code:
......
......
unzFile uf = unzOpen("MyFile.gz");
......
But Visual Studio 2013 crashes with this message:
Debug Assertion Failed!
file open.c
line 98
Expression: ("Invalid file open mode",0)
What could it mean?
A .gz file is a single file that's been compressed.
A .zip file is a compressed archive; i.e. a hierarchical structure of compressed files.
tl;dr minizip doesn't support .gz files as it's not a .zip file.

Compression is not working in ZLib library

I want to zip a already existing file in a directory, I am calling deflate method
int def(FILE *source, FILE *dest, int level) of ZLib library and I'm getting zipped file (making a file with .zip extension), but the problem is when I'm trying to unzip it by double clicking, I'm getting corrupted file though the return value is Z_OK.
PS: want to compress file not data. Any Help???
zlib does not produce the zip format. You would need to generate your own zip headers and trailers around the deflate compressed data produced by zlib.

How should you write the prep stage when the source file is a .gz?

The setup macro cannot handle a .gz file. I think I should extract the source .gz file without deleting it (decompressing with gzip deletes the file normally), and then manually cd into the uncompressed directory.
I am wondering if this is a good solution.
You cannot extract a directory from just a .gz file. That would be a .tar.gz file. The extraction of a .tar.gz file does not normally delete the .tar.gz file.

How to uncompress and import a .tar.gz file in kettle?

I am trying to figure out how to create a job/transformation to uncompress and load a .tar.gz file. Does anyone have any advice for getting this to work?
you want to read a text file that is compressed?
Just specify the file in the text file input step in the transformation - and specify the compression (GZip). Kettle can read directly from compressed files.
If you do need the file uncompressed then use a job step - not sure if there is a native uncompress, but if not just use a shell script step.
There is not such component in kettle to uncompress the tar.gz file i found.
But if we have the csv file text compressed in gizip format we can use gzip input component.