mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Fix FileSystem in devspace when path contains spaces
This commit is contained in:
parent
cf83f5d82b
commit
a07cadd1b0
23
src/main/scala/li/cil/oc/server/fs/FileSystem.scala
Normal file → Executable file
23
src/main/scala/li/cil/oc/server/fs/FileSystem.scala
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
package li.cil.oc.server.fs
|
package li.cil.oc.server.fs
|
||||||
|
|
||||||
import java.io
|
import java.io
|
||||||
import java.net.URL
|
import java.net.{URISyntaxException, MalformedURLException, URL}
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
import li.cil.oc.OpenComputers
|
import li.cil.oc.OpenComputers
|
||||||
@ -17,6 +17,8 @@ import net.minecraft.item.ItemStack
|
|||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraftforge.common.DimensionManager
|
import net.minecraftforge.common.DimensionManager
|
||||||
|
|
||||||
|
import scala.util.Try
|
||||||
|
|
||||||
object FileSystem extends api.detail.FileSystemAPI {
|
object FileSystem extends api.detail.FileSystemAPI {
|
||||||
lazy val isCaseInsensitive = Settings.get.forceCaseInsensitive || (try {
|
lazy val isCaseInsensitive = Settings.get.forceCaseInsensitive || (try {
|
||||||
val uuid = UUID.randomUUID().toString
|
val uuid = UUID.randomUUID().toString
|
||||||
@ -50,17 +52,18 @@ object FileSystem extends api.detail.FileSystemAPI {
|
|||||||
else
|
else
|
||||||
(codeSource, false)
|
(codeSource, false)
|
||||||
|
|
||||||
val file = try {
|
val url = Try {
|
||||||
val url = new URL(codeUrl)
|
new URL(codeUrl)
|
||||||
try {
|
}.recoverWith {
|
||||||
new io.File(url.toURI)
|
case _: MalformedURLException => Try {
|
||||||
|
new URL("file://" + codeUrl)
|
||||||
}
|
}
|
||||||
catch {
|
|
||||||
case _: Throwable => new io.File(url.getPath)
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
case _: Throwable => new io.File(codeSource)
|
|
||||||
}
|
}
|
||||||
|
val file = url.map(url => new io.File(url.toURI))
|
||||||
|
.recoverWith {
|
||||||
|
case _: URISyntaxException => url.map(url => new io.File(url.getPath))
|
||||||
|
}.getOrElse(new io.File(codeSource))
|
||||||
|
|
||||||
|
|
||||||
if (isArchive) {
|
if (isArchive) {
|
||||||
ZipFileInputStreamFileSystem.fromFile(file, innerPath.substring(1))
|
ZipFileInputStreamFileSystem.fromFile(file, innerPath.substring(1))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user