Miyako 4d-plugin-zip ZIP_Without_enclosing_folder

Bonjour Keisuke, bonjour à tous, (approximative english after the french :roll:)

J’ai un dossier A qui contient deux dossiers B et C, chacun contenant des fichiers.
J’ai besoin de zipper les dossiers B et C dans un seul fichier zip mais sans le dossier supérieur A.

J’ai essayé de zipper ‘A’ avec l’option ZIP_Without_enclosing_folder, mais cela ne change rien (à moins que je n’aie pas su bien placer l’option ?)

J’ai pensé à zipper B puis C, mais quand je zippe C, cela me remplace B par C au lieu de le rajouter dans le fichier zip.

Avez-vous une solution ?

Merci d’avance !

Philippe

Hello,

I have a A folder, with inside 2 folders B and C. B and C contain files.
I need to have a ZIP with B and C at the first level, without A.

I tried to ZIP A with ZIP_Without_enclosing_folder but it doesn’t work (unless I didn’t wrote it well ?)

I tried to ZIP B then ZIP C, but I obtain only C in my ZIP file.

Can you help me ?

Thanks a lot !

Philippe

<code 4D>
$success:=Zip ($DossierA;$ZipFile;’’;1;ZIP_Without_enclosing_folder)
</code 4D>

the difference between using ZIP_Without_enclosing_folder and not,

is that when you unarchive something.zip, you get ‘something’ as the root folder name instead of ‘a’.

the number of folders do not change.

today, I updated the plugin to support passwords and 7z format, as well as collection support,
but the behaviour of ZIP_Without_enclosing_folder does not change. there is always 1 root folder.

https://github.com/miyako/4d-plugin-zip

Bonsoir,

J’ai utilisé pour la première fois votre plug-in en utilisant uniquement la commande Unzip.
Mon environnement de développement : 4D v16R5 32-bit sur OSX 10.12.6.
J’ai téléchargé la dernière mise à jour de votre plug-in aujourd’hui.

C’est une application 4D fusionné qui est compressée que je tente de décompresser.
Cette archive a été compressé par 4D lors de sa compilation.

Je la décompresse avec le code suivant :
$Err:=Unzip ($Mon fichier . zip;$Mon dossier de décompression)
Au final l’application 4D décompressé ne se lance même pas.

Si je double clic dans le Finder sur l’archive, elle se décompresse très bien et fonctionne parfaitement.

Merci de votre aide

Pascal Aubert

UpSide Informatique

: Keisuke MIYAKO

there is always 1 root folder

Thank you for your answer but I am very annoyed. The process of our customer which get the Zip back needs to don’t have this root folder. As it is a big company, we do not have the power to make them change it :frowning:

Do you think it will be complex to modify your plug-in to get this specific need ?

I do ont know if it will be easer to create directly a Zip without the root folder or let the possibility to add an other folder in an existing .zip (I could in this way zip B then C…).

Hope you can help me to find a possibility ! :pray:

Thank you very much,

Philippe

I don’t know how that is possible with zip:

I created this zip file;

http://forums.4d.com/4DBB_Main/x_User/298210/files/26038458.zip

with the code

$path_a:=Get 4D folder(Current resources folder)+‘a’+Folder separator
CREATE FOLDER($path_a;*)

$path_b:=Get 4D folder(Current resources folder)+‘b’+Folder separator
CREATE FOLDER($path_b;*)

$src:=JSON Stringify(New collection($path_a;$path_b))

$dst:=System folder(Desktop)+Current method name+’.zip’

$pass:=’’

$success:=Zip ($src;$dst;$pass;0)

if you run zipinfo, contains 2 folders only, at the top level.

[]26038465;‘Your comment here…’[/]

as you can see,

miyakonoMacBook-puro:~ miyako$ zipinfo /Users/miyako/Desktop/test_zip_a_b_c.zip
Archive: /Users/miyako/Desktop/test_zip_a_b_c.zip
Zip file size: 214 bytes, number of entries: 2
?--------- 6.3 osx 0 bl stor 18-Sep-05 10:07 a/
?--------- 6.3 osx 0 bl stor 18-Sep-05 10:07 b/
2 files, 0 bytes uncompressed, 0 bytes compressed: 0.0%

but if I double click it, I get the 2 folders created inside a top level ‘test_zip_a_b_c’ folder.

that’s how zip works.

you need to pass ZIP_With_attributes to restore file attributes and symbolic links.

$src:=System folder(Desktop)+‘Chess.zip’
$dst:=System folder(Desktop)+Current method name+Folder separator

$success:=Unzip ($src;$dst;’’;ZIP_With_attributes)

on the other hand, the plugin’s unzip command,
unlike double-clicking the file,
restores the 2 folders at the top level.

$src:=Get 4D folder(Current resources folder)+‘test_unzip_a_b_c_7z.7z’
$dst:=System folder(Desktop)

$success:=Unzip ($src;$dst)

http://forums.4d.com/4DBB_Main/x_User/298210/files/26038602.7z

so it is really a problem of the unarchiver, not the zip command.

Thank you for your suggestion. I will test it and give the result to my customer.
I will tell you the result.

Have a good day !

Philippe

Bonjour Keisuke,

I forgot to say that I am in v16, we need 3 months more to stabilize our v17 version…

I tried to put in $src the same result that we obtain with collection in v17, but the zip command return 0.

I use the Zip 1.5 bundle, I do not see newer on github.

I do not know what to do :frowning:

Philippe

the repository has 2 branches

https://github.com/miyako/4d-plugin-zip/tree/classic-minizip

which stops at 1.5

and

https://github.com/miyako/4d-plugin-zip/tree/master

which goes up to 2.1

you can also go to releases

https://github.com/miyako/4d-plugin-zip/releases

the same plugin can be used for v14 to v17,
although only v17 can be preemptive because that is a new feature on the side of 4D.

Keisuke,

Thank you a lot for your help, it works fine in v16 with the last version and a simple code like this :

<code 4D>
TABLEAU TEXTE($MonTab;2)
$MonTab{1}:=$DossierA
$MonTab{2}:=$DossierA
$src:=JSON Stringify tableau($MonTab)
$Ok:=Zip ($src;$ZipFile;’’;0)
</code 4D>

You are great !

Amicalement,

Philippe