revZip external
Björnke von Gierke
bvg at mac.com
Thu Feb 10 15:59:34 EST 2011
I told you it's possible. please stop saying it is not. It's hard and unwieldily and neither you nor i want to do it, but nontheless it is possible to do it.
see also this non-complete example by trevor:
> You can use revZip if you want. Here are two (uncommented) handlers I use for zipping/unzipping folders. When zipping you can probably just concern yourself with the first 3 params.
>
> I should point out that you need to open/close the zip archive outside of the handlers I provided.
>
>
> Regards,
>
> --
> Trevor DeVore
> Blue Mango Learning Systems
> www.bluemangolearning.com - www.screensteps.com
>
>
>
> -- Leave pFolderPath empty. It is used recursively
> command zipAddFolderToArchive pZipArchivePath, pRootFolderPath, pIncludeRootFolderInArchiveItemNames, pFilesToExclude, pExtensionsThatArentCompressed, pFolderPath
> local theArchiveItemName,theCharNo,theError,theFile
> local theFiles,theFolder,theFolders
>
> put pIncludeRootFolderInArchiveItemNames is true into pIncludeRootFolderInArchiveItemNames
> set the wholematches to true
>
> replace comma with cr in pExtensionsThatArentCompressed
>
> if pFolderPath is empty then
> put pRootFolderPath into pFolderPath
> if pIncludeRootFolderInArchiveItemNames then
> set the itemdel to slash # we want folder to be reflected in archive item name
> delete item -1 of pRootFolderPath
> end if
> end if
>
> put fileFilesInFolder(pFolderPath, true, true) into theFiles
> filter theFiles without ".DS_Store"
> set the itemdel to "."
>
> repeat for each line theFile in theFiles
> if theFile is among the lines of pFilesToExclude then next repeat
>
> 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)
>
> if item -1 of theArchiveItemName is among the lines of pExtensionsThatArentCompressed then
> revZipAddUncompressedItemWithFile pZipArchivePath, theArchiveItemName, theFile
> else
> revZipAddItemWithFile pZipArchivePath, theArchiveItemName, theFile
> end if
> if the result is not empty then
> put the result into theError
> exit REPEAT
> end if
> end REPEAT
>
> if theError is empty then
> put fileFoldersInFolder(pFolderPath, true, true) into theFolders
> repeat for each line theFolder in theFolders
> zipAddFolderToArchive pZipArchivePath, pRootFolderPath, pIncludeRootFolderInArchiveItemNames, pFilesToExclude, pExtensionsThatArentCompressed, theFolder
> put the result into theError
> if theError is not empty then
> exit REPEAT
> end if
> end REPEAT
> end if
>
> return theError
> end zipAddFolderToArchive
>
>
> command zipDecompressArchiveToFolder pZipArchivePath, pOutputFolder, pItemsToExclude, pCallbackHandler
> local theError
>
> if the last char of pOutputFolder is slash then delete the last char of pOutputFolder
>
> set the wholematches to true
> put the filetype into theFileType
> set the filetype to empty
>
> put revZipEnumerateItems(pZipArchivePath) into theArchiveItems
> put the number of lines of theArchiveItems into theItemCount
>
> repeat for each line theArchiveItem in theArchiveItems
> add 1 to i
>
> if theArchiveItem is among the lines of pItemsToExclude then next repeat
>
> put pOutputFolder & slash & theArchiveItem into theFilePath
> put fileExtractDirectory(theFilePath) into theDirectoryPath
>
> if theDirectoryPath is not pOutputFolder then
> fileCreateAllFoldersInPath theDirectoryPath, pOutputFolder
> put the result into theError
> end if
>
> if theError is empty then
> if pCallbackHandler is not empty then
> put CardOf(the long id of the target) into theCard
> put "send" && quote & pCallbackHandler && "i, theItemCount" & quote && "to theCard" into theDo
> do theDo
> end if
>
> revZipExtractItemToFile pZipArchivePath, theArchiveItem, theFilePath
> put the result into theError
> end if
>
> if theError is not empty then exit REPEAT
> end REPEAT
>
> set the filetype to theFileType
>
> return theError
> end zipDecompressArchiveToFolder
>
> function fileFilesInFolder pFolder, pFullPath, pIncludeHidden
> local theDefault,theFile,theFiles,theFullFiles
>
> if there is not a folder pFolder then return empty
> if last char of pFolder is not slash then put slash after pFolder
>
> put the defaultfolder into theDefault
> set the defaultfolder to pFolder
> put the files into theFiles
> set the defaultfolder to theDefault
> if pIncludeHidden is not true then
> filter theFiles without ".*"
> else
> filter theFiles without "..*"
> end if
>
> if pFullPath then
>
> repeat for each line theFile in theFiles
> put pFolder & theFile & cr after theFullFiles
> end REPEAT
> delete last char of theFullFiles
> return theFullFiles
> else
> return theFiles
> end if
> end fileFilesInFolder
>
On 10 Feb 2011, at 21:54, Klaus on-rev wrote:
> Hi all,
>
> Am 10.02.2011 um 21:40 schrieb Björnke von Gierke:
>
>> it was always possible to zip a folder. as long as you go and recoursively add all the stuff within the folder to the folder hieararchy within the zip. and do the reverse for unzipping of course.
>
> Again, that's what I wanted to avoid.
>
>> not trivial, but not impossible either.
>
> ...and tedious anyway :-)
>
>> (note: haven't done it myself)
>
> AHA! :-D
>
> So my conclusion is, although noone answered my question directly, one cannot ZIP a folder INCLUDING the folder!
>
> But what about unZIPping an archive created from the outside that DOES include a folder or two?
> Anyone tried this and succeeded?
>
> And another, more rhetoric question, why can every cheap-o ZIP app do this but RevZip can't?
>
> This was an enhancement request from june 2007 from Bill Marriot himself:
> <http://quality.runrev.com/qacenter/show_bug.cgi?id=4945>
>
>
> Best
>
> Klaus
>
> --
> Klaus Major
> http://www.major-k.de
> klaus at major.on-rev.com
>
>
> _______________________________________________
> 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