Compression and Decompression of multiple files

Alex Rice alex at mindlube.com
Fri Feb 6 12:27:36 EST 2004


On Feb 6, 2004, at 9:44 AM, Thomas Hampson wrote:
>
> Has anyone got any ideas as to how revolution could compress the files
> and subfolders of a folder?

Maybe search the list archives- I'm sure this has come up in the past.  
The problem is Gzip is just a single file or single stream compression 
tool. You would have to use ZIP or TAR, or something else from a shell 
command, to get multiple files into an archive.

How about this as an alternative? Use a data stack as a container for 
multiple files:

(untested)

-- archive
go stack "archive.rev"
set the uFile1 of this stack to URL "binfile:file1.txt"
set the uFile2 of this stack to URL "binfile:file2.txt"
...
save this stack
put compress(URL "binfile:archive.rev") into URL "archive-rev.gz"

-- unarchive
put uncompress(URL "binfile:archive-rev.gz") into URL "archive.rev"
go stack "archive.rev"
put the uFile1 of me to URL "file1.txt"
put the uFile2 of me to URL "file2.txt"
...

There could be commands to loop through lists of files to make it more 
flexible. I haven't tested any of this but it seems like it would work 
OK

on mouseup
   local tFileList
   create stack "gzArchiveTest"
   put "binfile:/Users/alex/Desktop/apg.pdf" & linefeed after tFileList
   put "binfile:/Users/alex/Desktop/bpg.pdf" & linefeed after tFileList
   put "binfile:/Users/alex/Desktop/es-screens.pdf" & linefeed after 
tFileList
   gzArchiveAddFiles "gzArchiveTest", tFileList
end mouseup

on gzArchiveAddFiles pStackname, pFileList
   local tLastStack, tLine, tLineNo, tPropName

   put this stack into tLastStack
   if there is not a stack pStackname then exit gzArchiveAddFiles
   go stack pStackname
   if the short name of this stack <> pStackname then ext 
gzArchiveAddFiles
   set the uFileCount of this stack to the number of lines of pFileList
   set the uManifest of this stack to pFileList 	
   repeat for each line tLine in pFileList
     add 1 to tLineNo
     if tLine = empty then next repeat
     put "uFile" & tLineNo into tPropName
     set the tPropName of this stack to URL tLine
   end repeat
   go stack tLastStack
end gzArchiveAddFiles


--
Alex Rice | Mindlube Software | http://mindlube.com



More information about the use-livecode mailing list