I have searched the forum, and found many algorithms for compressing a file, but now I have a program that opens a specified directory and prompts the user where he wants to save the file, then adds the whole directoy and subdirectories to the archive.

Which compression algorithm should I use, and how?
Posted on 2002-03-31 09:45:31 by Nordbon
Which compression algorithm to choose depends on the data you're
compressing. ZIP is a good allround algorithm, with reasonable
speed/compression balance, and sourcecode is available.
To store a whole directory in an archive, you'll obviously need some
file headers describing name, original and packed sizes, data, etc...
you can look at how .zip is structured for an example.

If you're going to implement your own format, I recommend using
"solid compression", as it can reduce filesize a lot.
Posted on 2002-03-31 10:38:20 by f0dder
It's a compression program designed to work together with Martin (go Denmark ;)) LightJockey, to transfer files (cues and sequences) between computers (it is implemented in LightJockey, but it doesn't work as good as expected), it's a couple of hundred small files (~1k).
In the earliest stage of this program (that was written in VB, to be ported to another language) I used an ActiveX control that created CAB files, and they could save a structure. I just wonder if there are any dll's or something like that I can use, I'm not going to write my own compression algorithm here.
Posted on 2002-03-31 11:09:18 by Nordbon
There is a very well written compression library in the example code of MASM32 by JIBZ that handles mixed binary and text data well.

It is licenced as free for personal use and paid for with a modest sum for commercial usage so it may be worth you having a look at it.


Posted on 2002-03-31 16:23:35 by hutch--
aPLib is pretty nice, but it's main advantages are small decoder
size and fast decompression speed - the compressor is pretty slow.
Something like zip with solid compression sounds like a good idea
for "a bunch" of small files. But since you'd have to rework zip quite
a bit to do that, you might as well want to try your own compression,
fileformat etc - and aPLib is definitely worth giving a go.
Posted on 2002-03-31 18:34:15 by f0dder

I can se the aPLib is included in the MASM32 package, but isn't that compression just for one file? I want to compress n entire directory with it's subfolders down to a single archive. I can't see any other lib included with MASM32, or am I blind? ;)


Exactly, I need a compression like the Zip, Bzip2, Tar, Gzip, Ace, Rar, Cab, or any other compression like them, it don't have to be written in ASM, the source doesn't even have to be included, i just want something i can call from ASM (my program).
Posted on 2002-04-01 02:58:48 by Nordbon
Like f0dder said, to compress multiple files you'll have to design your own file format. Have a look at www.wotsit.org and read the ZIP or any other compressed file format description. You'll get an idea of what to do.

Posted on 2002-04-01 03:25:58 by Thomas

If you don't want to code the format yourself, Winrar will do what you are after through its command line interface. It is a commercial program that must be purchased but you will be hard pressed to improve on its compression ratio and you can make SFX modules with it as well that unpack in silent mode.


Posted on 2002-04-01 06:02:11 by hutch--

When this program was first ever built, it used the rar.exe to compress the directory, it was simple, it did the recursing of subfolders all by it self and such things. It had a few cons, though: I couldn't capture the error code, so if it failed with the compression, the program didn't knew this. It was limited to DOS 8.3 filenames, wich was very annoying, when you wanted to save something with a long name. So if there are any routines to capture the DOS output and get the exit code (which I know there are, but not how) I can go back to use that again.
Posted on 2002-04-01 06:24:25 by Nordbon
I use the 32 bit GUI version of winrar and it has command line support. Probably the easiest thing to do is download the trial version and have a play with it.

I bought it myself as its the best I have seen and the SFX modules work well. Just be warned that the help file is russian english and its no joy to read but the technical data is there.


Posted on 2002-04-01 06:51:16 by hutch--
OK, I'll just download the WinRAR and see what I can do...

Thanks everyone!
Posted on 2002-04-01 07:15:26 by Nordbon