Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] zip / gzip native multiplatfrom plugin

Discussion in 'Assets and Asset Store' started by elias_t, Jul 8, 2015.

  1. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hi.

    Sorry for your first issue. This is a problem that comes from the Asset Store. Many users upgraded from zip->7zp,lzma... without issues. Please contact the Unity Asset Store team. If you cannot resolve your issue tell me and I will contact them also.

    2. This issue is solved in the next version, which is still in beta. But I can send you the 1.44beta. There you should set for windows os "lzip.setEncoding(65001);" to get the desired encoding.

    Send me a personal message with your email so I can send you the beta version.
     
  2. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    321
    When you say "encryption is not supported," do you mean it is not a feature of the asset or it is not possible to use this with encryption?

    I am looking to use this in combination with Easy Save and it's encryption.
     
  3. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hi.

    Version 1.43 does not support encryption/decryption of password protected zip archives.

    However 1.44 will. It is in a final stage of testing before getting uploaded to the Asset Store.
     
  4. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    update version 1.44 [Major Update]

    (The previous 1.43 version has been kept as a unitypackage file.)


    - Added Encryption/Decryption support.

    - Added bz2 as an alternative compression/decompression method of zip archives.

    - WSA supports now FileBuffers.

    - On WSA encryption is supported only on UWP10 x64.

    - Better Unicode support on Windows platforms.

    - Faster and more reliable getInfo function. (intermediate file is not used anymore.)

    - Low level functions have been removed due to inconsistency between platforms.

    - Added the ability to compress a list of files into a single archive.
     
  5. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    HOTFIX notification for iOS builds (1.44 version and up):

    In your project's "Build Settings->Linking->Other Linker flags" add -lz

    Screen Shot 2017-09-25 at  22.41.37.png
     
  6. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hi all.

    There is an issue with the bz2 method in the last update on MacOS/iOS platforms. Avoid using this method for now on these platforms until a fix.
     
  7. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    update version 1.44.2

    - iOS/MacOS Hotfix.

    - bz2 method removed for MacOS/iOS/watchOS/tvOS because it is not working correctly.
     
  8. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    update version 1.45

    - Disabled encryption/decryption for WSA due to certification reasons.
     
  9. tomihr2

    tomihr2

    Joined:
    Oct 25, 2010
    Posts:
    29
    Is there some file size restriction now, because after I updated your plugin I can't unzip my 350mb zip file before it worked fine?
     
  10. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hello. There should be no file restriction.

    On what platform do you have this issue and with which app did you create the zip?

    because the newer updates have changed I am including in the package also the previous 1.43 version.

    I will look into it.
     
  11. tomihr2

    tomihr2

    Joined:
    Oct 25, 2010
    Posts:
    29
    The zip file is created on the server, and I am trying to unzip in Editor and Android, it worked before the update.
    Had changed the zip file from your demo scene with my file, and unzip failed.
     
    Last edited: Oct 24, 2017
  12. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    It would help if you could send me a zip file that fails.
     
  13. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    In any case if you are not using encryption/decryption it is fine to revert to the 1.43 version
     
  14. tomihr2

    tomihr2

    Joined:
    Oct 25, 2010
    Posts:
    29
    The old version works.
     
  15. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    It could be the implementation of the deflate64 algorithm. Some servers produce zip file in this format and not all unzippers support it.
     
  16. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Ok. I nailed it down. It has to do with the deflate64 algo the produces the abortion.
     
  17. ArtyBrest

    ArtyBrest

    Joined:
    Feb 20, 2014
    Posts:
    10
    Hi, Elias.
    Could you please add a method to get date/time info for zip entry?
     
  18. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hi.

    I will try to add this in the next update.
     
  19. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Ok. I have created the function. I just need to test it on all platforms and I will update the Asset Store project.
     
  20. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    update version 1.46

    - Added the getEntryDateTime function, to get DateTime for a specific entry

    - Updated the file sample links of the demos, due to a server switch.
     
  21. harshavardhan_k

    harshavardhan_k

    Joined:
    Nov 24, 2017
    Posts:
    2
    Hi Elias,
    In the lzip.cs file, In the compressDir function you have this line:
    if (!includeRoot) s = s.Replace(root + "/", "");
    The issue I have faced with this is that it removes occurrence of the root everywhere in the path. For example, if the file path from root is something like "abc/def/qwertyabc/file.txt" where "abc/" is the root, the file gets placed as def/qwertyfile.txt (the second "abc/" aslo gets removed).
     
  22. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Yes. You are right about this one. I will upload a fix asap.

    The function is a high level one anyway so it would be easy for users to modify it.
     
  23. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366

    Ok. Use this instead of the previous line you mentioned and you should be ok:

    Code (CSharp):
    1. if (!includeRoot) s = s.Substring(root.Length + 1);
     
  24. harshavardhan_k

    harshavardhan_k

    Joined:
    Nov 24, 2017
    Posts:
    2
    Thank you Elias.
    Yes, this is easy to fix . We thought to let you know about this so that you could fix it.

    Thank you for the prompt reply :)
     
  25. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Thanks for finding this.
     
  26. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    update version 1.47

    - Added the entry2FixedBuffer function to decompress an entry to a fixed size buffer.

    - The getFileInfo is now much faster on zip archives with thousands of files.
     
  27. MapMan

    MapMan

    Joined:
    Oct 27, 2013
    Posts:
    38
    Hello

    I'm using method the following method to get info about contents of my .gz package:
    Code (CSharp):
    1. public static long getFileInfo(string zipArchive, string path = null, byte[] FileBuffer = null)
    The method returns -1, meaning "Input file not found". I tried using both a gz archive in the local file storage and a file buffer. Both return -1. Replicated on both Android and Windows Editor using latest Asset Store version of the plugin.

    Attached is an example file that can be used to replicate the problem. NOTE: Rename the file from test_file.txt.zip to test_file.txt.gz - gz files are not allowed as an attachment, zip files are.
     

    Attached Files:

  28. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hi.

    The getFileInfo function is meant to be used on .zip files and not on gz file containers.

    gz is usually used on tar files that contain multiple archives.

    If you want to get the uncompressed size of the gz file you can use this function:

    Code (CSharp):
    1. int gzipUncompressedSize = lzip.gzipUncompressedSize(File.ReadAllBytes(MyPath+"/test_file.txt.gz"));
     
    Last edited: Dec 11, 2017
  29. MapMan

    MapMan

    Joined:
    Oct 27, 2013
    Posts:
    38
    I want to get contents of the package and then decompress them. How do I do that then?
     
  30. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    In the testZip.cs of the demo, there is a gzip section. Look it up and follow it.

    The gzip implementation is mainly geared to work with buffers. But a full gz file stream and tar.gz support is planned.
     
  31. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
    Hi,

    I am a new to your "Zip / gzip Multiplatform Native Plugin" asset. I have an issue where when I run the code below, the code worked only if the directory (backgrounds folder in this case) of the zip archive entries already exists in the file system, if not the entries' directory won't be created automatically hence no files being extracted yet the result variable return 1 which means successfully run.

    Here's the image of the zip archive created using lzip.compress_file. It consists only a "Backgrounds" folder



    Code (csharp):
    1.  
    2. result = lzip.decompress_File(fileName, path, null, null, null, zipPassword);
    3. if (result != 1)
    4.   DebugExt.Log("Zip error code: " + result + "(" + fileName + ")");
    5.  
     
  32. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hello.

    I tried to reproduce the issue following your case but it all worked fine. Could you please send me the zip file in question to investigate?

    Thanks.
     
  33. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
  34. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Ok. It seems that there is a glitch when the zip archive is password protected, the directory is not created.
    I will try for a fix asap.
     
  35. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
    Hi,

    You are amazing. Your response is excellent.

    Thanks
     
  36. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hi. Thanks.

    I have pinpointed the issue. Which platforms interest you the most?
     
  37. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
    Hi,

    Sorry for late reply. The game is for Android and iOS. I am thinking you can take your time to fix the glitch, I can use without password archive and continue with work :),

    Thanks
     
  38. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Ok the issue is fixed. I am compiling and testing the platforms. I will upload to the Store later today. If you need it today contact me by be a private message.
     
  39. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    update version 1.49

    - Hotfix for password encoded zip files not creating folders.
    - Hotfix for the compressDir function.
     
  40. shadowfork

    shadowfork

    Joined:
    Jan 8, 2010
    Posts:
    167
    Hello, I'm having a little issue getting my app submitted on iOS for TestFlight.
    I have bitcode enabled, the documentation just says:
    (bitcode enabled iOS plugins are provided in the plugins/ios/bitcode folder.)

    but I'm not exactly sure what is the process to utilize those zip files mentioned on that folder.
    Where do I exactly place them? On the XCode project or within Unity Project / Plugin folder?

    Instruction is a little vague. Would appreciate any help to the right direction. Thanks!
     
  41. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hello.
    In the Assets\Plugins\iOS\bitcode folder you will find the compressed bitcode plugins.
    Decompress the one you need in the Assets\Plugins\iOS folder.
     
  42. shadowfork

    shadowfork

    Joined:
    Jan 8, 2010
    Posts:
    167
    Thank you for your prompt response.
    I'll give this a shot.
     
  43. GKiernozek

    GKiernozek

    Joined:
    Nov 16, 2013
    Posts:
    40
    Hello, I have a problem when I try to publish an app to the Windows Store, can you please help me with this?
    upload_2018-3-6_16-59-3.png
     
  44. Carbonn

    Carbonn

    Joined:
    Dec 2, 2016
    Posts:
    2
    I’m running into the same problem if I try to build an App for HoloLens with unity3d. Any hints???
     
  45. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    Is it possible to create a zip archive containing files/folders without writing to the device's system storage (in-memory only) between each file addition? It appears that you'd need to use buffer2File for each entry, which saves/loads each time. Example:

    Code (CSharp):
    1. lzip.buffer2File(9, "Test.zip", "File1.xml", file1Bytes, true);
    2. lzip.buffer2File(9, "Test.zip", "File2.xml", file2Bytes, true);
    3. lzip.buffer2File(9, "Test.zip", "File3.xml", file3Bytes, true);
    This would result in saving/loading "Test.zip" 3 times using the device's system storage.

    In my case, I don't need the .zip file ever persisting on the user's device because it is being sent remotely, so I'd also have a final step

    Code (CSharp):
    1. var zipBytes = File.ReadAllBytes("Test.zip");
    2. File.Delete("Test.zip");
    It seems like a lot of excessive file IO if I just need to create a zip in-memory.

    Is there any way to improve this?
     
  46. lbelanger

    lbelanger

    Joined:
    Apr 12, 2018
    Posts:
    1
    Hi,
    The error codes are documented for most methods in Instructions_ZIP.txt, but not for the GZip methods. Could you specify what the error codes mean? Thank you!
     
  47. Zogg

    Zogg

    Joined:
    Mar 28, 2009
    Posts:
    157
    I purchased this because I need to zip together several memory streams into a single compressed stream in WebGL. Unfortunately, this doesn't seem to be supported.

    Bummer.
     
  48. aciusa

    aciusa

    Joined:
    Apr 19, 2016
    Posts:
    9
    Hi Elias,

    I've recently started using your plugin and have run into an issue opening zip files created on windows on a mac. I am using zlib compression unencrypted and receive the error "unsupported compression method 99" when attempting to run unzip <path> via the terminal or "Error 1 - operation not permitted" if I simply double click the file. My software also seems unable to open the file on iOS so I suspect the problem there is related. If I compress the same file with the same code on a mac, I can open it on any system. I have attached a copy of the zip in question.

    Thank you
     

    Attached Files:

  49. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,366
    Hello.

    Thanks for your input. I will investigate this.

    The plugin undergoes a major rewrite now and will be out soon.
     
  50. aciusa

    aciusa

    Joined:
    Apr 19, 2016
    Posts:
    9
    I've identified my problem and found a solution. The issue was twofold, Mac cannot read windows AES encryption without a plugin and after stripping the encryption I found my problems were also caused by an alteration in the function call when updating from the Oct 2017 version to the Dec 2017 version. Specifically the reordering of archive and destination, as well as the addition of includeRoot as an optional call (either that or the version of the plugin I had inherited from the previous developer was significantly modified) caused my software to look for the archive contents in a directory that did not exist.
     
    elias_t likes this.