New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unzip the compressed zip under mac #342
Comments
I use the zip package made by mac computer, and then use C# SharpZipLib.dll to extract the zip of this mac, get the result of zero byte file, the file should not be zero byte. |
Hello! Please use the issue template when creating an issue like this. |
sharpZipLib version is 0.86.0.518, .NET version is Unity 3.5 .net Subset Base Class Libraries. var zipFile = File.OpenRead(m_currentUnzipItem.SrcZipFile);
m_currentUnzipItem.totalSize = (int)zipFile.Length;
ZipInputStream unzipStream = new ZipInputStream(zipFile);
try
{
if (m_unzipProcessList.IndexOf(m_currentUnzipItem) < 0)
{
m_unzipProcessList.Add(m_currentUnzipItem);
}
ZipEntry theEntry;
while ((theEntry = unzipStream.GetNextEntry()) != null)
{
//先创建目录
string fullName = m_currentUnzipItem.ToDir + theEntry.Name;
string dir = Path.GetDirectoryName(fullName);
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
Debuger.Log("file={0}, dir={1}", theEntry.Name, dir);
if (theEntry.IsFile)
{
if (File.Exists(fullName))
{//删除原有文件
//File.Delete(fullName);
}
FileStream streamWriter = File.Create(fullName);
try
{
//unzipStream.Seek(theEntry.Offset, SeekOrigin.Begin);
int readTotalLen = 0;
while (readTotalLen < theEntry.Size)
{
Array.Clear(UnzipBuffer, 0, UnzipBuffer.Length);
int readlen = unzipStream.Read(UnzipBuffer, 0, UnzipBuffer.Length);
readTotalLen += readlen;
streamWriter.Write(UnzipBuffer, 0, readlen);
streamWriter.Flush();
m_currentUnzipItem.unzipedSize = (int)zipFile.Position;
//Debuger.Log("unzip={0}, total={1}, m_currentUnzipItem.stopUnzip:{2}", m_currentUnzipItem.unzipedSize, m_currentUnzipItem.totalSize, m_currentUnzipItem.stopUnzip);
if (m_currentUnzipItem.stopUnzip)
{
break;
}
}
}
catch (Exception ex)
{
Debuger.Error("解压出错1:{0},{1}", m_currentUnzipItem.SrcZipFile, ex.ToString());
m_currentUnzipItem.errorCode = ZipErrorCode.SingleFileError;
}
streamWriter.Close();
streamWriter.Dispose();
}
if (m_currentUnzipItem.stopUnzip)
{
break;
}
}
}
catch(Exception ext)
{
Debuger.Error("解压出错2:{0},{1}", m_currentUnzipItem.SrcZipFile, ext.ToString());
m_currentUnzipItem.errorCode = ZipErrorCode.ZipFileError;
} Compressed files by default zip mode on MAC computer, right-click file name, create compressed files The problem is unzipStream. GetNextEntry (). size is - 1L; |
Can that happen if the archive is using Zip64? (I couldn't say offhand if the macOS zip tool produces those) |
Yeah, this seems related to Zip64. Are you able to try the latest package? I'm not too familiar with using packages in unity, but I think the lastest version should support .NET standard. |
The latest version does not have DLL packages |
Can you give me a latest version of the DLL package? I can't install the nupkg file. Thank you. |
The nupkg is just a zip file, you should be able to just extract it and copy the dlls out of it. |
Probably caused by #357 |
Closing this as it should have been fixed in latest release. |
Hello, author, would you like to ask your SharpZipLib.dll package to extract the zip package compressed by mac? Have you ever encountered a zip package that is compressed under the mac, and the zero-byte file is coming out.
The text was updated successfully, but these errors were encountered: