![]() Registered Member ![]()
|
Hello everybody, I was trying to write a simple program that compress a user-specified folder, but I don't know how to create the archive. I gave a look at KArchive class and its subclasses, but still it's not clear.
As for the type of compression, I'd like to use either tar.gz, tar.bz2 or zip. Thanks |
![]() Registered Member ![]()
|
If you want to write a front end to the shell command, the command is
The letter "j" sends it all through bz2 compression. Alternatively, "z" would be the gz compression. It will do the job recursively for you through the subdir-structure. I believe you'd use full paths for archive and directory to be compressed. I do not know whether there is a letter for zip compression. There is always another syntax for archiving/compression with piping (key | ) where one command pipes its output into the next: in that case the commands being tar and zip, including there options/flags. But you would have to figure that one out... Have fun. |
![]() Registered Member ![]()
|
Or enter these URLs into konqueror for more information:
man:zip man:7za |
![]() Registered Member ![]()
|
Ok, thank you very much for the tips! Can you please tell me how to execute commands in my program? Do I have to use something like system("command"), or is there another way to do that?
|
![]() KDE Developer ![]()
|
I haven't used this API myself yet, but from the documentation my guess would be like this:
Cheers, _
anda_skoa, proud to be a member of KDE forums since 2008-Oct.
|
![]() Registered Member ![]()
|
Yeah, I guessed the same thing and tried it in tar.gz (adding mimetype to archive constructor), but then my program "freezed"...
It wasn't freeze, my program was compressing a big size folder because of an error in path settings... Now it works with KArchive API, thanks everyone for your quick answers! ![]() |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]