revZip functions, compressing and extracting folder for transfer

Matt Maier blueback09 at gmail.com
Thu Apr 6 16:49:50 EDT 2017


I pulled the zip archiving functions out of the Master Library stack.

It worked...except that it truncated the first character of every filename
in the archive.

This is the offending code from the addFolderToArchive handler:
put theFile into theArchiveItemName
put offset(pRootFolderPath, theArchiveItemName) into theCharNo
if theCharNo is 0 then return "file is not in expected folder"
delete char 1 to (the number of chars of pRootFolderPath + 1) of
theArchiveItemName # strip root folder up to slash (zip item names
shouldn't start with a slash)

The value I see for pRootFolderPath includes the ending slash, so the "+ 1"
here is deleting the first character of the filename.

Can I just remove the "+ 1"? Will that make it work on Windows but fail on
another system?

On Sat, Mar 4, 2017 at 12:49 PM, Phil Davis via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Here is a sanitized version of a simple zip library stack I use in
> projects. It keeps me from having to get down into the nuts and bolts every
> time I want to zip a file:
>
>    https://www.dropbox.com/s/t8z27p8cy5ir1v9/libZip.livecode?dl=0
>
> HTH -
> Phil Davis
>
>
>
> On 3/4/17 9:25 AM, Matt Maier via use-livecode wrote:
>
>> Is there an overview or tutorial on how to use the revZip functions?
>>
>> Do I have to use each individual function to manually describe the process
>> of creating and using a zip archive?
>>
>> Like, to create the archive, do I have to write my own code to open it,
>> repeat for each file and/or each folder, find and specify the name and
>> contents and format of each file, then close it, then remember to delete
>> it
>> later...or is there a command somewhere that just takes a folder and
>> returns a zipped version of that folder?
>>
>> The same question for extracting an archive. Do I have to open it,
>> enumerate the files, repeat for each file and/or folder, figure out that
>> file's name, contents, and format, copy the file to an appropriate new
>> file, then close it, then remember to delete it later...or is there a
>> command that just takes a *.zip and returns an extracted folder?
>>
>> I already spent a couple hours trying various combinations of quotes
>> around
>> the parameters to add something to an archive before I figured out put the
>> data into the URL as a binfile manually. Then this morning I ran across a
>> different revZip function to add a file directly, instead of raw data,
>> which I guess is what I was doing. So it would be nice to find out that
>> there's already a function that does all of the obvious zip archive stuff
>> automatically and correctly.
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
> --
> Phil Davis
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list