revZipper

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

revZipper

Post by jmburnod » Fri May 07, 2010 7:04 pm

Hi All,

I used the "revZipper.rev" stack of the revolution resource center
I selected an archives which contains one standalone in one folder.

The extraction of the archive by the finder work fine,
i have the folder with the standalone and i can launch the standalone

revZipEnumerateItems return a list of 87 lines

and the extraction by "revZipper.rev" is like that
resultrevZipper.png
resultrevZipper.png (10.27 KiB) Viewed 5666 times
and i can't launch the standalone
Same results with powerbook G4 10.4.2 and Intel core 2 duo 10.5.6

Thank one more for your help

Best

Jean-Marc
https://alternatic.ch

kotikoti
Posts: 72
Joined: Tue Apr 15, 2008 7:35 pm

Re: revZipper

Post by kotikoti » Sat May 08, 2010 4:17 pm

Hi Jean-Marc,
have used rev zip functionality recently and here's the code to extract the files and directories after using the enum.. command to list the content of the zip file

Code: Select all

revZipOpenArchive tempFilename, read
    put revZipEnumerateItems(tempFilename) into archiveFiles
     
    repeat with i = 1 to (the number of lines of archiveFiles)
       
      if last char of line i of archiveFiles  is "/" then
        put tempDir & "/" & line i of archiveFiles into newDir
        repeat forever
          if  there is no folder newDir then
            create folder newDir
            wait 2 ticks
          else
            put newDir into _newDir
            delete last char of _newDir
            put _newDir &cr after allFiles
            exit repeat
          end if
        end repeat
      else 
        put tempDir &"/" & line i of archiveFiles into tempFile 
        if matchtext(tempFile,".html") then
          put tempFile into toExecute
        end if
        revZipExtractItemToFile tempFilename, line i of archiveFiles, tempFile
        wait 2 ticks
      end if
    end repeat
Just remember to open the archive for read as shown in first line.

The above code hence trawls through the list and where it finds a directory, creates the directory as well...

Hope this is what you are missing in your code or will help someone too.

P.S On windows myself...

kotikoti
Build 160
Version 2.9.0
Platform: Windows

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: revZipper

Post by jmburnod » Sat May 08, 2010 6:15 pm

Hi kotikoti,

Thank for help
For one standalone i have a big list in archiveFiles (87) and if i understand your script, it create a folder for each line with a "/" at last char ?

Probably it's different on OSX

Best

Jean-Marc
https://alternatic.ch

kotikoti
Posts: 72
Joined: Tue Apr 15, 2008 7:35 pm

Re: revZipper

Post by kotikoti » Sun May 09, 2010 1:25 pm

Hi Jean-Marc
Under Windows, the listing will show directories ending with the "/" item, and code will create this directory, subsequently files that reside in that directory will be created properly. I am not familiar with how Mac works but you can paste in here the output of the list and code to achieve the same would be easier for me and maybe someone using Mac to put together. my code uses TempDir as a variable to hold the current directory name (was not sure if this was easy to note)

Code: Select all

AVI712X392/
AVI712X392/AVI712X392.html
AVI712X392/AVI712X392_media/
AVI712X392/AVI712X392_media/AVI712X392.avi
AVI712X392/AVI712X392_media/AVI712X392_player_embed.js
In the list above, my archive would be unzipped into the directory AVI712X392 hence first line would be found to be for a directory, and code will duly create the directory. Second item is a file hence will just deal with as normal. Third line again a directory hence create it etc etc...

In brief, I assume if a directory does not exist the rev zip methods will not be able to create files that are in that subdirectory.
Build 160
Version 2.9.0
Platform: Windows

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: revZipper

Post by jmburnod » Sun May 09, 2010 3:52 pm

Hi kotikoti,

i have this long list for on standalone in one folder (many lines ending with the "/") :

Code: Select all

unehorlogeosx/
unehorlogeosx/.DS_Store
__MACOSX/
__MACOSX/unehorlogeosx/
__MACOSX/unehorlogeosx/._.DS_Store
unehorlogeosx/UneHorloge.app/
unehorlogeosx/UneHorloge.app/Contents/
unehorlogeosx/UneHorloge.app/Contents/Info.plist
__MACOSX/unehorlogeosx/UneHorloge.app/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/._Info.plist
unehorlogeosx/UneHorloge.app/Contents/MacOS/
unehorlogeosx/UneHorloge.app/Contents/MacOS/Externals/
unehorlogeosx/UneHorloge.app/Contents/MacOS/UneHorloge
unehorlogeosx/UneHorloge.app/Contents/PkgInfo
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/._PkgInfo
unehorlogeosx/UneHorloge.app/Contents/PlugIns/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/Info.plist
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/._Info.plist
unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/MacOS/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/MacOS/coreimage_support
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/MacOS/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/MacOS/._coreimage_support
unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/PkgInfo
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/coreimage_support.bundle/Contents/._PkgInfo
unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/Info.plist
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/._Info.plist
unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/MacOS/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/MacOS/jaguar_theme_support
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/MacOS/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/MacOS/._jaguar_theme_support
unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/PkgInfo
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/jaguar_theme_support.bundle/Contents/._PkgInfo
unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/Info.plist
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/._Info.plist
unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/MacOS/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/MacOS/panther_theme_support
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/MacOS/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/MacOS/._panther_theme_support
unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/PkgInfo
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/panther_theme_support.bundle/Contents/._PkgInfo
unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/Info.plist
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/._Info.plist
unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/MacOS/
unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/MacOS/tiger_theme_support
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/MacOS/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/MacOS/._tiger_theme_support
unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/PkgInfo
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/PlugIns/tiger_theme_support.bundle/Contents/._PkgInfo
unehorlogeosx/UneHorloge.app/Contents/Resources/
unehorlogeosx/UneHorloge.app/Contents/Resources/da.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/Dutch.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/English.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/fi.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/French.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/German.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/Italian.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/Japanese.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/ko.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/no.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/Spanish.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/sv.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/UneHorloge.rsrc
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/Resources/
__MACOSX/unehorlogeosx/UneHorloge.app/Contents/Resources/._UneHorloge.rsrc
unehorlogeosx/UneHorloge.app/Contents/Resources/zh_CN.lproj/
unehorlogeosx/UneHorloge.app/Contents/Resources/zh_TW.lproj/
unehorlogeosx/UneHorloge.app/Icon

__MACOSX/unehorlogeosx/UneHorloge.app/._Icon

unehorlogeosx/._UneHorloge.app
https://alternatic.ch

kotikoti
Posts: 72
Joined: Tue Apr 15, 2008 7:35 pm

Re: revZipper

Post by kotikoti » Mon May 10, 2010 9:22 am

Is the code not working for you?

From you list provided, was that output from revZipEnumerateItems(filename)? I noted that from your list some files do appear down the list and not in any order as expected. Under windows I believe the zip system will add files to the archive sequentially: meaning, directory created followed by the files associated with that directory, and if any other directoried reside within that the process is repeated.
As mentioned, not familiar with Mac but assume the same is followed.

what you can try is get that list and sort it in say a spreadsheet and see what the order would be, and in rev code provided, you can trap file/directory creation errors.


for file

Code: Select all

if the result is not empty then
answer "Error in creating of file: " && line i of archiveFiles
end if
for folder

Code: Select all

if the result is not empty then
answer "Error in creating of folder: " && line i of archiveFiles
end if

Code: Select all

revZipOpenArchive tempFilename, read
    put revZipEnumerateItems(tempFilename) into archiveFiles
     
    repeat with i = 1 to (the number of lines of archiveFiles)
       
      if last char of line i of archiveFiles  is "/" then
        put line i of archiveFiles into newDir
        repeat forever
          if  there is no folder newDir then
            create folder newDir
            if the result is not empty then
              answer "Error in creating of folder: " && line i of archiveFiles
            end if
            wait 2 ticks
          else
            exit repeat
          end if
        end repeat
      else 
        put line i of archiveFiles into tempFile 
        revZipExtractItemToFile tempFilename, line i of archiveFiles, tempFile
        if the result is not empty then
          answer "Error in creating of file: " && line i of archiveFiles
        end if
        wait 2 ticks
      end if
    end repeat
Build 160
Version 2.9.0
Platform: Windows

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: revZipper

Post by jmburnod » Tue May 11, 2010 5:50 pm

Hi kotikoti,

Thank for your help

I have a script to extract files of an archives if there is a stack inside, but not if there is a standalone
On Mac a standalone is a package with folders and subfolders.
I think that is the problem

Jean-Marc
https://alternatic.ch

Post Reply