Unzipping zip files?

Is there a way to decompress zip files in Xojo?
I found a zip maker plugin online for xojo, but it’s the extracting of zip files that I am interested in!
Anybody got any code snippets?

Well, MBS Plugin has Zip functions…
Also Thomas Tempelmann has zip class. And not to forget various command line tools.

[quote=63729:@Sean Clancy]Is there a way to decompress zip files in Xojo?
I found a zip maker plugin online for xojo, but it’s the extracting of zip files that I am interested in!
Anybody got any code snippets?[/quote]

If you are on Mac, you can use the shell to extract zip files.

and windows?

Expand
The expand command is used to extract a single file or a group of files from a compressed file.
The expand command is available in MS-DOS as well as in all versions of Windows. The expand command is not available in the 64-bit version of Windows XP.

EXPAND source [/F:filespec] [destination] [/Y]
EXPAND source [/F:filespec] /D
source Specifies the file to be expanded. May not include wildcard (* and ?) characters.
Destination Specifies the directory for the new file. The default is the current directory.
/y Do not prompt before overwriting an existing file.
/f:filespec If the source contains more than one file, this parameter is required to identify the< specific file(s) to be expanded. May include wildcards.
/d Do not expand; only display a directory of the files that are contained in the source.

Unzipping your files through the Terminal is an easy process that begins with navigating to the folder where the zip file is stored. After doing that, type the following command:

unzip x

Replace x in the above command with the name of the zip file (including the “.zip” file extension). When you press enter, the command will be run and the contents of the zip file will be unzipped to the same location where the zip file is located.

Seems you got everything covered…

Well… I always give the answers as other people with the same questions get a fully comprehensive guide.

If we all do that, this forum would be even better!

Great practice. Congratulations !

Have used this information to get my program to unzip files but if the file name is not in the dos 8.3 format then the command returns an error code of 254 and does not unzip the file.

Any help will be appreciated.

I have not heard about Dos 8.3 in so long I had forgotten that under todays long names Dos still keeps faithfully a list of shorter names. This is so ancient that I even forgot the API call that can fetch the Dos name.

You will probably not need that. Have you placed quotes around your file name ? Like

expand "this is my file.zip" d:/myfolder

It could account for the error.

If you still need the Dos name, use Folderitem.ShellPath in your shell. The Dos name is there at the end. No need to dive into declares.

Hi Michel,

Have used quote marks as that’s why I get the error code.

Will try your Shellpath and let you know as is time I was resting.

Ian

I tried before posting in the command line and it works line a charm. Are you sure it is a matter of Dos name ? Could it not be some path issue or a mistype ?

You may want to test the string you shell in the command line prompt program and see what happens.

Same thing for the shellPath.

It is always prudent to test with the command line prompt before going shell or batch. It is much easier to debug.

Hi Michel,

Could not wait so tried your suggestion and you are correct as it now unzips any file I point it to dos or windows.

Thank You as i should have read the Folderitem properties list before asking.

Thank You Very Much

under linux it seems that unzip is not installed by default distributions and you must issue a “apt-get install zip” to get it
is there a way to know from xojo that unzip is not installed in the shell ?

the aim is to make an unzip function in xojo that works under mac, win and linux.
thanks.

won’t using “f.LAUNCH” work? where f is a folderitem pointing to the zip file?
assuming you have a ZIP app installed (which of course OSX does)

[quote=138807:@jean-yves pochez]under linux it seems that unzip is not installed by default distributions and you must issue a “apt-get install zip” to get it
is there a way to know from xojo that unzip is not installed in the shell ?[/quote]

Go shell.execute("zip") and see in result what you get. If it is “unknown command” or something to that effect zip is not installed.

how about using a plugin?
http://www.monkeybreadsoftware.de/xojo/plugin-compression.shtml

Nobody has yet to say why this is not a viable solution… because it does seem to work

  dim f as FolderItem
  f=SpecialFolder.Desktop.child("x.txt.zip")
  f.Launch

and it works with OSX and Win7

No shell, no plugins, cross platform… simple.

[quote=138930:@Dave S]Nobody has yet to say why this is not a viable solution… because it does seem to work

  dim f as FolderItem
  f=SpecialFolder.Desktop.child("x.txt.zip")
  f.Launch

and it works with OSX and Win7

No shell, no plugins, cross platform… simple.[/quote]

f.launch indeed works for Mac and Windows but not for Linux if zip has not been installed. However, command line allows to have a silent extraction and put the files elsewhere.

Besides, it behaves differently. On Mac the files are extracted next to the archive. On Windows it opens like a folder and the user has to take the files out manually. But still on Windows, many users have apps installed like Winzip that have an even different behavior.