- Bug fix. Handle zip exception in ProcessZipFile instead of one of the call sites.

This commit is contained in:
jfrijters 2013-02-17 07:11:02 +00:00
Родитель c7c72d7a9d
Коммит eccdd76000
1 изменённых файлов: 43 добавлений и 43 удалений

Просмотреть файл

@ -1318,22 +1318,24 @@ sealed class IkvmcCompiler
}
private void ProcessZipFile(CompilerOptions options, string file, Predicate<ZipEntry> filter)
{
try
{
string jar = Path.GetFileName(file);
ZipFile zf = new ZipFile(file);
try
{
foreach(ZipEntry ze in zf)
foreach (ZipEntry ze in zf)
{
if(filter != null && !filter(ze))
if (filter != null && !filter(ze))
{
// skip
}
else if(ze.IsDirectory)
else if (ze.IsDirectory)
{
options.AddResource(ze, ze.Name, null, jar);
}
else if(ze.Name.ToLower().EndsWith(".class"))
else if (ze.Name.ToLower().EndsWith(".class"))
{
AddClassFile(options, ze, ze.Name, ReadFromZip(zf, ze), true, jar);
}
@ -1341,19 +1343,19 @@ sealed class IkvmcCompiler
{
// if it's not a class, we treat it as a resource and the manifest
// is examined to find the Main-Class
if(ze.Name == "META-INF/MANIFEST.MF" && manifestMainClass == null)
if (ze.Name == "META-INF/MANIFEST.MF" && manifestMainClass == null)
{
// read main class from manifest
// TODO find out if we can use other information from manifest
StreamReader rdr = new StreamReader(zf.GetInputStream(ze));
string line;
while((line = rdr.ReadLine()) != null)
while ((line = rdr.ReadLine()) != null)
{
if(line.StartsWith("Main-Class: "))
if (line.StartsWith("Main-Class: "))
{
line = line.Substring(12);
string continuation;
while((continuation = rdr.ReadLine()) != null
while ((continuation = rdr.ReadLine()) != null
&& continuation.StartsWith(" ", StringComparison.Ordinal))
{
line += continuation.Substring(1);
@ -1372,6 +1374,11 @@ sealed class IkvmcCompiler
zf.Close();
}
}
catch (ICSharpCode.SharpZipLib.SharpZipBaseException x)
{
throw new FatalCompilerErrorException(Message.ErrorReadingFile, file, x.Message);
}
}
private void ProcessFile(CompilerOptions options, DirectoryInfo baseDir, string file)
{
@ -1383,14 +1390,7 @@ sealed class IkvmcCompiler
break;
case ".jar":
case ".zip":
try
{
ProcessZipFile(options, file, null);
}
catch(ICSharpCode.SharpZipLib.SharpZipBaseException x)
{
throw new FatalCompilerErrorException(Message.ErrorReadingFile, file, x.Message);
}
break;
default:
{