mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -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] {
|
Option(cache.get(file.getPath + ":" + innerPath, new Callable[ArchiveDirectory] {
|
||||||
def call = {
|
def call = {
|
||||||
val zip = new ZipFile(file.getPath)
|
val zip = new ZipFile(file.getPath)
|
||||||
|
try {
|
||||||
val cleanedPath = innerPath.stripPrefix("/").stripSuffix("/") + "/"
|
val cleanedPath = innerPath.stripPrefix("/").stripSuffix("/") + "/"
|
||||||
val rootEntry = zip.getEntry(cleanedPath)
|
val rootEntry = zip.getEntry(cleanedPath)
|
||||||
val result = if (rootEntry != null && rootEntry.isDirectory) {
|
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 directories = mutable.Set.empty[ArchiveDirectory]
|
||||||
val files = mutable.Set.empty[ArchiveFile]
|
val files = mutable.Set.empty[ArchiveFile]
|
||||||
val iterator = zip.entries()
|
val iterator = zip.entries()
|
||||||
@ -111,9 +114,9 @@ object ZipFileInputStreamFileSystem {
|
|||||||
}
|
}
|
||||||
root
|
root
|
||||||
}
|
}
|
||||||
else null
|
finally {
|
||||||
zip.close()
|
zip.close()
|
||||||
result
|
}
|
||||||
}
|
}
|
||||||
})) match {
|
})) match {
|
||||||
case Some(archive) => new ZipFileInputStreamFileSystem(archive)
|
case Some(archive) => new ZipFileInputStreamFileSystem(archive)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user