mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -04:00
Add filename to FileNotFoundExceptions thrown in various filesystem implementations
This commit is contained in:
parent
214a0c2c30
commit
dbdc813fad
@ -301,7 +301,7 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option
|
|||||||
|
|
||||||
private def clean(path: String) = {
|
private def clean(path: String) = {
|
||||||
val result = com.google.common.io.Files.simplifyPath(path)
|
val result = com.google.common.io.Files.simplifyPath(path)
|
||||||
if (result.startsWith("../")) throw new FileNotFoundException()
|
if (result.startsWith("../")) throw new FileNotFoundException(path)
|
||||||
if (result == "/" || result == ".") ""
|
if (result == "/" || result == ".") ""
|
||||||
else result
|
else result
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ class CompositeReadOnlyFileSystem(factories: mutable.LinkedHashMap[String, Calla
|
|||||||
|
|
||||||
override def open(path: String, mode: Mode) = findFileSystem(path) match {
|
override def open(path: String, mode: Mode) = findFileSystem(path) match {
|
||||||
case Some(fs) => fs.open(path, mode)
|
case Some(fs) => fs.open(path, mode)
|
||||||
case _ => throw new FileNotFoundException()
|
case _ => throw new FileNotFoundException(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getHandle(handle: Int) = parts.valuesIterator.map(_.getHandle(handle)).find(_ != null).orNull
|
override def getHandle(handle: Int) = parts.valuesIterator.map(_.getHandle(handle)).find(_ != null).orNull
|
||||||
|
@ -38,7 +38,7 @@ trait FileInputStreamFileSystem extends InputStreamFileSystem {
|
|||||||
case file if file.exists() && file.isFile => Array(file.getName)
|
case file if file.exists() && file.isFile => Array(file.getName)
|
||||||
case directory if directory.exists() && directory.isDirectory && directory.list() != null =>
|
case directory if directory.exists() && directory.isDirectory && directory.list() != null =>
|
||||||
directory.listFiles().map(file => if (file.isDirectory) file.getName + "/" else file.getName)
|
directory.listFiles().map(file => if (file.isDirectory) file.getName + "/" else file.getName)
|
||||||
case _ => throw new io.FileNotFoundException("no such file or directory")
|
case _ => throw new io.FileNotFoundException("No such file or directory: " + path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -36,9 +36,9 @@ trait InputStreamFileSystem extends api.fs.FileSystem {
|
|||||||
case Some(channel) =>
|
case Some(channel) =>
|
||||||
handles += handle -> new Handle(this, handle, path, channel)
|
handles += handle -> new Handle(this, handle, path, channel)
|
||||||
handle
|
handle
|
||||||
case _ => throw new FileNotFoundException()
|
case _ => throw new FileNotFoundException(path)
|
||||||
}
|
}
|
||||||
} else throw new FileNotFoundException())
|
} else throw new FileNotFoundException(path))
|
||||||
|
|
||||||
override def getHandle(handle: Int): api.fs.Handle = this.synchronized(handles.get(handle).orNull)
|
override def getHandle(handle: Int): api.fs.Handle = this.synchronized(handles.get(handle).orNull)
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ trait OutputStreamFileSystem extends InputStreamFileSystem {
|
|||||||
case Some(fileHandle) =>
|
case Some(fileHandle) =>
|
||||||
handles += handle -> fileHandle
|
handles += handle -> fileHandle
|
||||||
handle
|
handle
|
||||||
case _ => throw new FileNotFoundException()
|
case _ => throw new FileNotFoundException(path)
|
||||||
}
|
}
|
||||||
} else throw new FileNotFoundException()
|
} else throw new FileNotFoundException(path)
|
||||||
})
|
})
|
||||||
|
|
||||||
override def getHandle(handle: Int): api.fs.Handle = this.synchronized(Option(super.getHandle(handle)).orElse(handles.get(handle)).orNull)
|
override def getHandle(handle: Int): api.fs.Handle = this.synchronized(Option(super.getHandle(handle)).orElse(handles.get(handle)).orNull)
|
||||||
|
@ -33,8 +33,8 @@ private class ReadOnlyWrapper(val fileSystem: api.fs.FileSystem) extends api.fs.
|
|||||||
|
|
||||||
override def open(path: String, mode: Mode) = mode match {
|
override def open(path: String, mode: Mode) = mode match {
|
||||||
case Mode.Read => fileSystem.open(path, mode)
|
case Mode.Read => fileSystem.open(path, mode)
|
||||||
case Mode.Write => throw new FileNotFoundException()
|
case Mode.Write => throw new FileNotFoundException("Read-only filesystem; cannot open for writing: " + path)
|
||||||
case Mode.Append => throw new FileNotFoundException()
|
case Mode.Append => throw new FileNotFoundException("Read-only filesystem; cannot open for appending: " + path)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getHandle(handle: Int) = fileSystem.getHandle(handle)
|
override def getHandle(handle: Int) = fileSystem.getHandle(handle)
|
||||||
|
@ -67,7 +67,7 @@ trait VirtualFileSystem extends OutputStreamFileSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override def rename(from: String, to: String) =
|
override def rename(from: String, to: String) =
|
||||||
if (from == "" || !exists(from)) throw new FileNotFoundException()
|
if (from == "" || !exists(from)) throw new FileNotFoundException(from)
|
||||||
else if (!exists(to)) {
|
else if (!exists(to)) {
|
||||||
val segmentsTo = segments(to)
|
val segmentsTo = segments(to)
|
||||||
root.get(segmentsTo.dropRight(1)) match {
|
root.get(segmentsTo.dropRight(1)) match {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user