zip and unzip archives lazarus / 32-Linux ---------------------------------------------------------------------- Mangafreak1995 · 2010-09-29 21:46 Hey lazarus-guys, I'm using a TProcess to execute the 'zip' and 'unzip' command. But it doesn't work fine. Unzipping works very well, but when I execute sth like this : 'zip /home/myname/desktop/file.zip /tmp/myapp/' it zips but it contains only the folder tmp -> myapp. When I execute this : 'zip -r /home/myname/desktop/file.zip /tmp/myapp/' it zips everything in the /tmp/myapp/ folder but in the archive there are also those two subdirectories again. I want the files from the folder /tmp/myapp/ in the archive without subdirectories (but the subdirs of /tmp/myapp/). What am I doing wrong or what param makes this working ? Mangafreak1995 ---------------------------------------------------------------------- fabienwang · 2010-09-29 22:23 try to use: http://wiki.lazarus.freepascal.org/ZipFile ---------------------------------------------------------------------- Mangafreak1995 · 2010-09-30 04:11 Installation was easy and without any problems. When I make a zipfile using this code: Code: [Select]var dir : String;     ZipFile : TZipFile; begin      try         dir := GetTempDir + 'working';         ForceDirectories(dir);         Img.Picture.PNG.SaveToFile(dir + '/img1.png');         Img1.Picture.PNG.SaveToFile(dir + '/img2.png');         ZipFile.FileName := strFile;         ZipFile.Activate();         ZipFile.AppendFileFromDisk(dir + '/img1.png', ZipFile.FileName);         ZipFile.AppendFileFromDisk(dir + '/img2.png', ZipFile.FileName);         ZipFile.Active := false;      except            // ...I get an error when I wan to open this zipfile with the Archivemanager. QuoteArchive:  /home/myname/Desktop/myarchive.zip [/home/myname/Desktop/myarchive.zip]   End-of-central-directory signature not found.  Either this file is not   a zipfile, or it constitutes one disk of a multi-part archive.  In the   latter case the central directory and zipfile comment will be found on   the last disk(s) of this archive. zipinfo:  cannot find zipfile directory in one of /home/myname/Desktop/myarchive.zip or           /home/myname/Desktop/myarchive.zip, and cannot find /home/myname/Desktop/myarchive.zip, period. ---------------------------------------------------------------------- Ocye · 2010-09-30 08:29 zip /home/myname/desktop/file.zip /tmp/myapp/* ---------------------------------------------------------------------- Mangafreak1995 · 2010-09-30 14:33 thanks ---------------------------------------------------------------------- Mangafreak1995 · 2010-09-30 17:24 well, or not. It's the same problem. But I found some kind of documentation: http://linux.about.com/od/commands/l/blcmdl1_zip.htm. I used the param -j . This makes zip ignore the pathes and only takes the files without any directory-prefixes. My current code is : Code: [Select]// PathIt is a function replacing the spaces(' ') with '\ ' // ExecuteProcess makes a process executing the query and wait until it's done // strFile : String = file to create or replace // dir : TempDir (in this case '/tmp/') + 'appname' ShowMessage('zip -jr ' + PathIt(strFile) + ' ' + dir + '*'); ExecuteProcess('zip -jr ' + PathIt(strFile) + ' ' + dir + '*');When I copy the command from the messagebox and paste it into the console it works. But executeprocess doesnt work ---------------------------------------------------------------------- Ocye · 2010-10-01 09:10 ExecuteProcess() reveals errorcode in the result, and maybe raises error as well. All other "doesn't work" advisements are crystal-ball- reading. If you don't use ZIP deliberately you should take GZIP into account. It's available on all Linux in contrast to ZIP which often needs to be installed extra.