revZipExtractItemToFile: merge or replace?

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
trevix
Posts: 1017
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

revZipExtractItemToFile: merge or replace?

Post by trevix » Wed Sep 25, 2024 2:16 pm

Does anyone know if doing a revZipExtractItemToFile, of a Zip file containing a folder named "X, to a directory where there is already a folder named "X, there is a merge, a replace or else?
In the dictionary I could not find a reference on this.

By the way, I have a few questions on the Zip stuff, on LC 10:
- is there a RevZip external to be enabled somewhere for mobiles?
- what is the "Revolution ZIP" extension?
Thanks
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9727
Joined: Fri Feb 19, 2010 10:17 am

Re: revZipExtractItemToFile: merge or replace?

Post by richmond62 » Wed Sep 25, 2024 2:25 pm

Why not try that out to find the answer?

trevix
Posts: 1017
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by trevix » Wed Sep 25, 2024 2:29 pm

I did, but could not come to a final verdict.
I am working for mobile devices, where things are more complex.
Beside, if the existing folder contains an open stack, I have to close it first (destroy) so that it get replaced by the one from the zip file. But somehow it seems that the stack is still in memory sometime. Could be "timing"?
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Klaus
Posts: 13962
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by Klaus » Wed Sep 25, 2024 3:33 pm

Hi Trevix,

here a handler which I "borrowed" from the LC IDE, this will close and remove a stack from memory COMPLETELY!:

Code: Select all

command closeAndRoveFromMemory tStack
   local tSubstacks
   put the subStacks of stack tStack into tSubstacks  
   lock messages
   repeat for each line tSubStack in tSubstacks
      close stack tSubStack
   end repeat
   delete stack tStack
   unlock messages
end closeAndRoveFromMemory
Hope that helps!

Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9727
Joined: Fri Feb 19, 2010 10:17 am

Re: revZipExtractItemToFile: merge or replace?

Post by richmond62 » Wed Sep 25, 2024 6:31 pm

closeAndRoveFromMemory
strikes me as very odd indeed: might closeAndRemoveFromMemory be better?

Klaus
Posts: 13962
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by Klaus » Wed Sep 25, 2024 6:40 pm

Oops, never had a deeper look!? :shock:

I copied this from a LC lesson PDF, and that (copying text from PDF files) tends to "lose" some chars from time to time.
And of course it correctly reads "closeAndRemoveFromMemory" in the PDF.

trevix
Posts: 1017
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by trevix » Tue Oct 01, 2024 8:58 am

I can confirm that revZipExtractItemToFile does a merge: new files are added, same name files are replaced, but old files not present in the zip are not deleted.
By the way: why unzipping on LC is so much slower than a OS unzip (not even comparable)?
Is there anything that can be done on this regard?
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9958
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by FourthWorld » Tue Oct 01, 2024 4:57 pm

How large is the archive?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevix
Posts: 1017
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by trevix » Tue Oct 01, 2024 10:24 pm

36MB uncompressed.
On OS, unzipping is about 3 secs on Sonoma
LC UnZip, using the routine with status bar, 20 or more seconds.

Code: Select all

 -- Open the archive for reading.
     revZipOpenArchive pArchive, "read"
     -- As the work happens in the revZipExtractItemToFile in this case, we register the callback here.
     revZipSetProgressCallback "zipProgressCallback"
     
     repeat for each line tItem in sZipListOfFiles
          if char -1 of tItem is "/" then
               -- we ignore extraction of folders, as libzip doesnt handle folders
          else if item 6 of revZipDescribeItem(pArchive,tItem) is "deflate" then
               -- first make sure that the folder exists
               set the itemDel to "/"
               ensureFolder tLocation & "/" & item 1 to -2 of tItem
               set the itemDel to ","
               revZipExtractItemToFile pArchive, tItem, tLocation & "/" & tItem
          else
               put true into tCouldNot
          end if
     end repeat
     revZipCloseArchive pArchive
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9958
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by FourthWorld » Wed Oct 02, 2024 1:00 am

36 MBs fits into RAM nicely. I wonder if it's faster to read the files into an array and then encode and compress the array to store on disk.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1224
Joined: Thu Apr 11, 2013 11:27 am

Re: revZipExtractItemToFile: merge or replace?

Post by LCMark » Wed Oct 02, 2024 6:04 am

@trevix: What is `zipProgressCallback` doing? Try not setting a progress callback and seeing what the speed is.

trevix
Posts: 1017
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: revZipExtractItemToFile: merge or replace?

Post by trevix » Wed Oct 02, 2024 3:39 pm

Your were right, as usual.
Without the callback it is almost instantaneous.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”