提交 01348d08 authored 作者: Thomas Mueller's avatar Thomas Mueller

File system bugfixes

上级 8d934127
......@@ -57,7 +57,11 @@ public class FilePathZip extends FilePath {
return true;
}
ZipFile file = openZipFile();
try {
return file.getEntry(entryName) != null;
} finally {
file.close();
}
} catch (IOException e) {
return false;
}
......@@ -93,6 +97,7 @@ public class FilePathZip extends FilePath {
return true;
}
ZipFile file = openZipFile();
try {
Enumeration<? extends ZipEntry> en = file.entries();
while (en.hasMoreElements()) {
ZipEntry entry = en.nextElement();
......@@ -107,6 +112,9 @@ public class FilePathZip extends FilePath {
}
}
}
} finally {
file.close();
}
return false;
} catch (IOException e) {
return false;
......@@ -127,8 +135,12 @@ public class FilePathZip extends FilePath {
public long size() {
try {
ZipFile file = openZipFile();
try {
ZipEntry entry = file.getEntry(getEntryName());
return entry == null ? 0 : entry.getSize();
} finally {
file.close();
}
} catch (IOException e) {
return 0;
}
......@@ -146,6 +158,7 @@ public class FilePathZip extends FilePath {
path += "/";
}
ZipFile file = openZipFile();
try {
String dirName = getEntryName();
String prefix = path.substring(0, path.length() - dirName.length());
Enumeration<? extends ZipEntry> en = file.entries();
......@@ -163,6 +176,9 @@ public class FilePathZip extends FilePath {
list.add(getPath(prefix + name));
}
}
} finally {
file.close();
}
return list;
} catch (IOException e) {
throw DbException.convertIOException(e, "listFiles " + path);
......@@ -179,6 +195,7 @@ public class FilePathZip extends FilePath {
ZipFile file = openZipFile();
ZipEntry entry = file.getEntry(getEntryName());
if (entry == null) {
file.close();
throw new FileNotFoundException(name);
}
return new FileZip(file, entry);
......@@ -368,6 +385,7 @@ class FileZip extends FileBase {
in.close();
in = null;
}
file.close();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论