attempt to read ZIP file even if central directory is broken (this should probably be a configurable setting)

This commit is contained in:
Michael Becker 2020-01-23 03:39:09 -05:00
parent 991cde070c
commit ff3cd09671
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7

View File

@ -132,6 +132,8 @@ namespace UniversalEditor.DataFormats.FileSystem.ZIP
}
else
{
// try from the beginning of the entire stream
br.Accessor.Position = 0;
Console.WriteLine("zip: central directory offset " + footer.centralDirectoryOffset.ToString() + " out of bounds for file (" + br.Accessor.Length.ToString() + ")");
}
}
@ -148,65 +150,12 @@ namespace UniversalEditor.DataFormats.FileSystem.ZIP
File file = null;
try
{
zip_ReadFile(br, fsom);
/*
if (file != null)
{
if (file.Name.Contains("/"))
{
// file is a directory entry or has directory entries defined, create the directory if it does not exist
string[] dirs = file.Name.Split('/');
file = zip_ReadFile(br, fsom);
Folder currentDir = null;
if (String.IsNullOrEmpty(dirs[dirs.Length - 1])) continue;
foreach (string dir in dirs)
{
if (Array.IndexOf(dirs, dir) < dirs.Length - 1)
{
if (currentDir != null)
{
if (!currentDir.Folders.Contains(dir))
{
currentDir = currentDir.Folders.Add(dir);
}
else
{
currentDir = currentDir.Folders[dir];
}
}
else
{
if (!fsom.Folders.Contains(dir))
{
currentDir = fsom.Folders.Add(dir);
}
else
{
currentDir = fsom.Folders[dir];
}
}
}
else
{
if (!String.IsNullOrEmpty(dir))
{
file.Name = dir;
currentDir.Files.Add(file);
}
}
}
}
else
{
fsom.Files.Add(file);
}
}
else
if (file == null)
{
break;
}
*/
}
catch (System.Security.SecurityException)
{