Compression is not working in ZLib library - objective-c

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.

Related

How to use a file from Common Voice Corpus

I downloaded the latest release of Mozilla's Common Voice. After unpacking the archive, I received a file of an unknown type. Who worked with this case? How do I get wav and txt files from it?
Okay, I get the problem. For some unknown reason, instead of ru.tar.gz ru.tar is downloaded and everything breaks. If you add it .gz archive unpacks normally

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

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.

Can't download and save srt file using DownloadFile

I want to download a srt (subtitles) file from subtitles4free.net but I can't understand how I am supposed to do it.
I tried downloading it using
My.Computer.Network.DownloadFile("http://www.getsubtitle.com/webService/download_subtitle.php?cod_bsplayer=38187011&post_date=11-06-2015", "C:\Users\User1\Downloads\subs.srt")
but the file that gets downloaded is a srt file containing some weird text, probably because it has to be a direct download url with a file extension. Is there any way to get this to work and if not, is there any other way of doing this?
The file format you are downloading is ZIP, not SRT. Save it as a .zip file. Extract it and you'll get the .srt file.

bunzip / bzip2 an entire directory instead of individual files in the directory

With gunzip its simply zip -r archive.zip my_dir/.
Am failing to find an equivalent command for bunzip. Some if found are zipping individual files inside of a directory, but i want one .bzip2 archive.
gunzip is not zip. zip is an archiver which handles files and directories. gzip/gunzip only compresses a single file or stream of data.
bzip2 is just like gzip, and only compresses a single file or stream of data. For both gzip and bzip2, it is traditional to use tar as the archiving program, and compressing the output. In fact that is such a common idiom that tar has options to invoke gzip or bzip2 for you. Do a man tar.

Objective-C NSString pathExtension for example.tar.gz?

When calling the pathExtension method on a string that contains something such as "example.tar.gz" I get ".gz" as the result. I can do some string manipulation to get the real extension, but I'm number wondering if there is a built in method that I'm overlooking? (I have checked the docs, but I don't see anything).
Obviously pathExtension is working as expected in this case. The documentation for pathExtension says:
The path extension is the portion of the last path component which
follows the final period, if there is one.
I can see where you are coming from with your example of a tarred gzipped file. However, I would say that .gz is the extension. Unzipping the file (with gzip) will result in a .tar file which can be extracted with tar.
I assume that the convention of naming files with the .tar.gz extension started before tar was able to also perform the gzip compression. The gzip application appends .gz to the filename of the file being compressed. For example, gzipping a log file, access.log, will result in a file called access.log.gz.
The .tgz extension has been used for tarred gzipped files particularly where the filename needs to be preserved on file systems that would mangle the extension (e.g. DOS).