Home > Archive > Compression > July 2006 > Folder Compression
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Folder Compression
|
|
|
| Dear All,
I am developing compression application in C++ (vs2k5) using zlib
library
for compressing files/folders. I understand how to compress a single
file,
but is there any way to compress a folder containing subfolder and
files? I
mean is there some single function that does this (using unmanaged
code).
regards,
-aims
| |
| cr88192 2006-07-26, 6:55 pm |
|
"Neo" <momer114@gmail.com> wrote in message
news:1153902703.283610.17760@75g2000cwc.googlegroups.com...
> Dear All,
>
> I am developing compression application in C++ (vs2k5) using zlib
> library
> for compressing files/folders. I understand how to compress a single
> file,
> but is there any way to compress a folder containing subfolder and
> files? I
> mean is there some single function that does this (using unmanaged
> code).
>
not sure how applicable in your case (c++ on windows).
but, have you checked, eg, readdir and stat?
now, these are c and posix (c++ and/or windows may provide alternatives).
note here this is not a single function, rather this would require
iteration, checking, and recursion...
now, as for zlib:
note that deflate is (solely) a compression algo;
also note that the gzip format (often used externally) is not much more than
a wrapper (a header and some other stuff), and can only compress a single
file.
for compressing multiple files or directories, you would need to use an
actual archive format or library (for example, zip, which uses deflate
internally).
I am sure there are libraries around, but I haven't looked into this.
in my case, I have my own archive format/library, but note that it is
something I made myself, so if you used it you would be about the only
one...
my format, the reason I made it initially, is that most other formats (zip
included) are unsuitible for read/write access (mine at least makes it
workable).
actually, I vaguely suspect that the valve gcf format is similar, but I
haven't looked into this much...
dunno if any of this helps any.
> regards,
> -aims
>
| |
| Matt Mahoney 2006-07-28, 6:55 pm |
| Neo wrote:
> Dear All,
>
> I am developing compression application in C++ (vs2k5) using zlib
> library
> for compressing files/folders. I understand how to compress a single
> file,
> but is there any way to compress a folder containing subfolder and
> files? I
> mean is there some single function that does this (using unmanaged
> code).
>
> regards,
> -aims
AFAIK there is no completely portable way to manipulate directories in
C/C++. The UNIX functions stat(), opendir(), readdir() and closedir()
work pretty much the same in g++ under Windows. You can even use
forward slashes in filenames. The most annoying difference is that
mkdir() takes 2 arguments in UNIX but one in Windows, and some headers
are named differently. I have to resort to #ifdefs and use the
windows.h equivalent functions like GetFileAttributes(),
FindFirstFile(), FindNextFile(), FindClose(), CreateDirectory(), etc.
to make it work with some Windows compilers. I did this in paq8f,
which you can compile with either -DUNIX or -DWINDOWS to get different
versions of makedir() and expand() for its folder
compression/decompression code.
http://cs.fit.edu/~mmahoney/compression/paq8f.cpp
-- Matt Mahoney
|
|
|
|
|