mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
made zip file system error instead of return null if the specified root path isn't a directory
This commit is contained in:
parent
b3a737c57c
commit
62f5a7a993
@ -82,9 +82,12 @@ object ZipFileInputStreamFileSystem {
|
||||
Option(cache.get(file.getPath + ":" + innerPath, new Callable[ArchiveDirectory] {
|
||||
def call = {
|
||||
val zip = new ZipFile(file.getPath)
|
||||
val cleanedPath = innerPath.stripPrefix("/").stripSuffix("/") + "/"
|
||||
val rootEntry = zip.getEntry(cleanedPath)
|
||||
val result = if (rootEntry != null && rootEntry.isDirectory) {
|
||||
try {
|
||||
val cleanedPath = innerPath.stripPrefix("/").stripSuffix("/") + "/"
|
||||
val rootEntry = zip.getEntry(cleanedPath)
|
||||
if (rootEntry == null || !rootEntry.isDirectory) {
|
||||
throw new IllegalArgumentException(s"Root path $innerPath doesn't exist or is not a directory in ZIP file ${file.getName}.")
|
||||
}
|
||||
val directories = mutable.Set.empty[ArchiveDirectory]
|
||||
val files = mutable.Set.empty[ArchiveFile]
|
||||
val iterator = zip.entries()
|
||||
@ -111,9 +114,9 @@ object ZipFileInputStreamFileSystem {
|
||||
}
|
||||
root
|
||||
}
|
||||
else null
|
||||
zip.close()
|
||||
result
|
||||
finally {
|
||||
zip.close()
|
||||
}
|
||||
}
|
||||
})) match {
|
||||
case Some(archive) => new ZipFileInputStreamFileSystem(archive)
|
||||
|
Loading…
x
Reference in New Issue
Block a user