Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

SharpZipLib working on mac, errorless failure on windows

Discussion in 'Scripting' started by JTown, Nov 13, 2015.

  1. JTown

    JTown

    Joined:
    Jan 9, 2010
    Posts:
    986
    Modified snippet from one of their examples:
    Code (CSharp):
    1.  
    2.             ZipFile zf = null;
    3.             try {
    4.                 FileStream fs2 = File.OpenRead(filenames);
    5.                 Debug.Log("Created FileStream " + ((fs2 == null) ? "but it's null" : "and it seemed to work"));      
    6.                 zf = new ZipFile(fs2);
    7.                 Debug.Log("Created ZipFile " + ((zf == null) ? "but it's null" : "and it seemed to work"));      
    8.                 //  if (!String.IsNullOrEmpty(password)) {
    9.                 //     zf.Password = password;     // AES encrypted entries are handled automatically
    10.                 //  }
    11.                 foreach (ZipEntry zipEntry in zf) {
    12.                     Debug.Log("Entry: " + zipEntry.Name);
    13.                     if (!zipEntry.IsFile) {
    14.                         continue;           // Ignore directories
    15.                     }
    16.                     String entryFileName = zipEntry.Name;
    17.                     // to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
    18.                     // Optionally match entrynames against a selection list here to skip as desired.
    19.                     // The unpacked length is available in the zipEntry.Size property.
    20.      
    21.                     byte[] buffer = new byte[4096];     // 4K is optimum
    22.                     Stream zipStream = zf.GetInputStream(zipEntry);
    23.      
    24.                     // Manipulate the output filename here as desired.
    25.                     String fullZipToPath = Path.Combine(target_directory, entryFileName);
    26.                     string directoryName = Path.GetDirectoryName(fullZipToPath);
    27.                     if (directoryName.Length > 0)
    28.                         Directory.CreateDirectory(directoryName);
    29.      
    30.                     // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
    31.                     // of the file, but does not waste memory.
    32.                     // The "using" will close the stream even if an exception occurs.
    33.                     using (FileStream streamWriter = File.Create(fullZipToPath)) {
    34.                         StreamUtils.Copy(zipStream, streamWriter, buffer);
    35.                     }
    36.                 }
    37.             }
    38.             finally {
    39.                 if (zf != null) {
    40.                     zf.IsStreamOwner = true; // Makes close also shut the underlying stream
    41.                     zf.Close(); // Ensure we release resources
    42.                 }
    43.             }
    44.             Debug.Log("Done unzipping");
    45.  
    On mac, it all unzips correctly. On windows, line 7 never gets printed and nothing after line 6 seems to execute. I don't get any errors, so I'm not sure what I can do about it..

    Running Unity 5.2.2f1 on mac, running the build on windows 7.
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    4,992
    Either try running it in debug on windows (install unity).

    Or add a 'catch' to your try catch, and log that exception somewhere.
     
    JTown likes this.
  3. JTown

    JTown

    Joined:
    Jan 9, 2010
    Posts:
    986
    Weird.. I'd tried catching earlier and got nothing. This time got "CodePage 437 not supported"

    Copied I18N.West.dll and I18N.dll from the Unity editor installation into Assets/Library and it works now. Thank god...
     
  4. Kubic75

    Kubic75

    Joined:
    Jan 2, 2017
    Posts:
    62
    Same error "CodePage 437 not supported" here on desktop..
    Could fix it from here:

    ICSharpCode.SharpZipLib.Zip.ZipConstants.DefaultCodePage = 0;
     
    Last edited: Sep 13, 2017