TTsZipPackage

TTsZipPackage now fails for Mac resource fork issues. I have communicated with Thomas, who is aware of the problem, but suggested I patch it myself. Since this is beyond my skill set, I am wondering if anyone else has it going again.

the apis for resource forks were removed from Xojo itself
that probably hampers things a bit

I gave up on TTsZipPackage many years ago and now use the MBS zip classes.

Someone emailed me about a few compilations errors in TTsZipPackage last October and I had this as a reply:

[quote]MacCreator, MacType and MacFSRef were removed from FolderItem in 2019r2. You can probably tweak the conditional compilation part of the code like this to avoid the error:

Old:

#If RBVersion >= 2010.05

New:

#If RBVersion >= 2010.05 And RBVersion < 2019.02

The Readable interface had the method EndOfFile added. You can get rid of that error by adding an empty EndOfFile method to ZipBinaryStreamReader.[/quote]

Not sure if this matches errors you are seeing, but hopefully this gets you started.

I did the same… It was not hard to make the transition.

if you move to MBS Xojo Compression Plugin classes, please check out the archive classes.

See /Compression/Archive/archive example.

i have tried to follow some of the suggestions here, but all seem to require digging into things deeper than i want to go. i need to simply compress a whole folder tree with a single command, then get it back with another single command, without needing to understand what is actually going on.

there seems to be an odd asymmetry at work. the monkeybread plug-ins seem to support the former, but i cannot find the equivalent for decompress. one of the example codes fails for its own references to macCreator, another is a terminal app, others seem to rely on knowing the number of files.

if there is a straightforward single command in there somewhere that takes a pointer to a zip file and decompresses it into its original folder tree, i would be grateful to know about it.

christian has been very accommodating via online chat, but i still do not see how to just decompress a zip file.

Mac only: zip / unzip a folder thru a shell, where you can bypass the SelectFolderDialog / OpenDialog and directly pass to “f” your folder / file.

dim dlg as new SelectFolderDialog dlg.InitialDirectory = SpecialFolder.Desktop dim f as FolderItem = dlg.ShowModalWithin(self) if f <> nil then dim s as new Shell s.Execute "cd " + f.Parent.shellpath + " ; zip -r " + f.ShellPath + " " + f.name end if

dim dlg as new OpenDialog dlg.InitialDirectory = SpecialFolder.Desktop dim f as FolderItem = dlg.ShowModalWithin(self) if f <> nil then dim destination as string = SpecialFolder.Desktop.Child("Uploads").ShellPath dim s as new Shell s.Execute "cd " + destination + " ; unzip -j " + f.ShellPath end if

All my routines us the old ZipFileInfoMBS, but we should now be using the newer ArchiveWriterMBS.

I can show you the older Methods if required. I have one routine to Zip a file and another for a folder. The folder Method is recursive — if it finds a file it calls the Zip file method, otherwise it looks inside the folder and calls itself.

[quote=481203:@Carlo Rubini]Mac only: zip / unzip a folder thru a shell, where you can bypass the SelectFolderDialog / OpenDialog and directly pass to “f” your folder / file.

dim dlg as new SelectFolderDialog
dlg.InitialDirectory = SpecialFolder.Desktop
dim f as FolderItem = dlg.ShowModalWithin(self)
if f <> nil then
dim s as new Shell
s.Execute "cd " + f.Parent.shellpath + " ; zip -r " + f.ShellPath + " " + f.name
end if
dim dlg as new OpenDialog
dlg.InitialDirectory = SpecialFolder.Desktop
dim f as FolderItem = dlg.ShowModalWithin(self)
if f <> nil then
dim destination as string = SpecialFolder.Desktop.Child(“Uploads”).ShellPath
dim s as new Shell
s.Execute "cd " + destination + " ; unzip -j " + f.ShellPath
end if[/quote]

Hi Carlos,

Thanks but I am getting some “Issues”, I have that code in PushButton20 in Window1MouseDown…

Window1.PushButton20.MouseDown, line 11
Redefined identifier. This name is already defined by variable dlg
dim dlg as new OpenDialog

Window1.PushButton20.MouseDown, line 13
Redefined identifier. This name is already defined by variable f
dim f as FolderItem = dlg.ShowModalWithin(self)

Any suggestions.

Thanks.

Lennox

dim g as FolderItem = dlg.ShowModalWithin(self)

and change other references to this f to g below…

ZipFileInfoMBS and other related methods are working fine for me, are there any particular reasons why or if I should rewrite to use ArchiveWriterMBS?

Thanks Emile,

But this still needs attention…
Window1.PushButton20.MouseDown, line 11
Redefined identifier. This name is already defined by variable dlg
dim dlg as new OpenDialog

Thanks again.

Lennox

[quote=481248:@John McKernon]ZipFileInfoMBS and other related methods are working fine for me, are there any particular reasons why or if I should rewrite to use ArchiveWriterMBS?
[/quote]
Not sure. ArchiveWriterMBS seems to do much more. Maybe Christian can answer us.

ZipFile is the old code, which doesn’t handle permissions or extended attributes.
If it works for you, that is fine.

ArchiveWriterMBS is a newer class, which support for file formats (e.g. tar) and can handle metadata, unicode and extended attributes.

Sorry for the code not being so clear: each snippet must be but in a different pushbutton.
By the way, I’m adding the shell for zipping also a file:

PushButton 1: Zip a folder:

Sub Action() Handles Action dim dlg as new SelectFolderDialog dlg.InitialDirectory = SpecialFolder.Desktop dim f as FolderItem = dlg.ShowModalWithin(self) if f <> nil then dim s as new Shell s.Execute "cd " + f.Parent.shellpath + " ; zip -r " + f.ShellPath + " " + f.name end if End Sub

PushButton 2: Zip a single file:

Sub Action() Handles Action dim dlg as new OpenDialog dlg.InitialDirectory = SpecialFolder.Desktop dim f as FolderItem = dlg.ShowModalWithin(self) if f <> nil then dim destination as string = f.Parent.Child("myArch.zip").ShellPath dim s as new Shell s.Execute "zip -j " + destination + " " + f.ShellPath end if End Sub

PushButton 3: Unzip a folder or a single file:

Sub Action() Handles Action dim dlg as new OpenDialog dlg.InitialDirectory = SpecialFolder.Desktop dim f as FolderItem = dlg.ShowModalWithin(self) if f <> nil then dim destination as string = SpecialFolder.Desktop.Child("Uploads").ShellPath dim s as new Shell s.Execute "cd " + destination + " ; unzip -j " + f.ShellPath end if End Sub

[quote=481294:@Christian Schmitz]ZipFile is the old code, which doesn’t handle permissions or extended attributes.
If it works for you, that is fine.

ArchiveWriterMBS is a newer class, which support for file formats (e.g. tar) and can handle metadata, unicode and extended attributes.[/quote]

What about un-zipping? Is there something new to use for that?

You can use the other archive classes…
Try examples.

[quote=481494:@Christian Schmitz]You can use the other archive classes…
[/quote]

Sounds good, thank you!