NativePath in Windows Using MBS Xojo Compression Plugin

I have an app that can be used to archive files where I’m using the MBS Xojo Compression plugin. I modified the code from the zip folder example project to give the user an option to preserve the original folder path in the archive file. The following code does that in macOS by recreating the original folder path within the archive file but in Windows it merely copies the specified files directly into the archive folder without creating the parent folders. I don’t know if this is an issue with the plugin or the result of differences between the file systems in macOS and Windows.

If not folder.Child(file.Parent.NativePath).Exists then folder.Child(file.Parent.NativePath).CreateAsFolder End if If folder.Child(file.Parent.NativePath) <> Nil and folder.Child(file.Parent.NativePath).Exists then file.CopyFileTo(folder.Child(file.Parent.NativePath)) Else file.CopyFileTo(folder) End if

I’ve not used the plugin in question but you can’t copy a folder structure in windows (without using a 3rd party tool like xcopy) you have to traverse and rebuilt it at the target location.

Ah, well, I was probably expecting too much from the plugin. I’ll have to add the code to do that in Windows.

Also, you shouldn’t pass a path to Child. You need to build it one level at a time.

Thanks for the tips. I’ll rework the code to do it that way.

If you compress a zip folder, please put a relative path in the zip archive.
And when you read the archive, build the folders as needed.

First the newer archive functions can do this:

http://www.monkeybreadsoftware.net/example-compression-archive-extractfilesinarchive.shtml

and lower level the old functions:

http://www.monkeybreadsoftware.net/example-compression-unzipwithfolders.shtml
http://www.monkeybreadsoftware.net/example-compression-zipfolder.shtml

See functions getpath and ParsePath to build folder item for the paths.

[quote=382950:@Christian Schmitz]First the newer archive functions can do this:

http://www.monkeybreadsoftware.net/example-compression-archive-extractfilesinarchive.shtml

and lower level the old functions:

http://www.monkeybreadsoftware.net/example-compression-unzipwithfolders.shtml
http://www.monkeybreadsoftware.net/example-compression-zipfolder.shtml

See functions getpath and ParsePath to build folder item for the paths.[/quote]
Thanks, I’ll take a look at those.

One idea is to shell to the 7zip or rar command line versions, which makes things easy.

I want to avoid using shell commands in this app, though, that’s why I’m using the MBS plugin.