diff --git a/src/main/scala/li/cil/oc/server/component/FileSystem.scala b/src/main/scala/li/cil/oc/server/component/FileSystem.scala index 9f470449a..b93ea5d54 100644 --- a/src/main/scala/li/cil/oc/server/component/FileSystem.scala +++ b/src/main/scala/li/cil/oc/server/component/FileSystem.scala @@ -301,7 +301,7 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option private def clean(path: String) = { 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 == ".") "" else result } diff --git a/src/main/scala/li/cil/oc/server/fs/CompositeReadOnlyFileSystem.scala b/src/main/scala/li/cil/oc/server/fs/CompositeReadOnlyFileSystem.scala index 096615ce7..ec717ebb2 100644 --- a/src/main/scala/li/cil/oc/server/fs/CompositeReadOnlyFileSystem.scala +++ b/src/main/scala/li/cil/oc/server/fs/CompositeReadOnlyFileSystem.scala @@ -72,7 +72,7 @@ class CompositeReadOnlyFileSystem(factories: mutable.LinkedHashMap[String, Calla override def open(path: String, mode: Mode) = findFileSystem(path) match { 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 diff --git a/src/main/scala/li/cil/oc/server/fs/FileInputStreamFileSystem.scala b/src/main/scala/li/cil/oc/server/fs/FileInputStreamFileSystem.scala index a405bb967..aae9728ac 100644 --- a/src/main/scala/li/cil/oc/server/fs/FileInputStreamFileSystem.scala +++ b/src/main/scala/li/cil/oc/server/fs/FileInputStreamFileSystem.scala @@ -38,7 +38,7 @@ trait FileInputStreamFileSystem extends InputStreamFileSystem { case file if file.exists() && file.isFile => Array(file.getName) case directory if directory.exists() && directory.isDirectory && directory.list() != null => 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) } // ----------------------------------------------------------------------- // diff --git a/src/main/scala/li/cil/oc/server/fs/InputStreamFileSystem.scala b/src/main/scala/li/cil/oc/server/fs/InputStreamFileSystem.scala index 82125ee33..cd61f41ba 100644 --- a/src/main/scala/li/cil/oc/server/fs/InputStreamFileSystem.scala +++ b/src/main/scala/li/cil/oc/server/fs/InputStreamFileSystem.scala @@ -36,9 +36,9 @@ trait InputStreamFileSystem extends api.fs.FileSystem { case Some(channel) => handles += handle -> new Handle(this, handle, path, channel) 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) diff --git a/src/main/scala/li/cil/oc/server/fs/OutputStreamFileSystem.scala b/src/main/scala/li/cil/oc/server/fs/OutputStreamFileSystem.scala index d6de4d06c..e53c99063 100644 --- a/src/main/scala/li/cil/oc/server/fs/OutputStreamFileSystem.scala +++ b/src/main/scala/li/cil/oc/server/fs/OutputStreamFileSystem.scala @@ -28,9 +28,9 @@ trait OutputStreamFileSystem extends InputStreamFileSystem { case Some(fileHandle) => handles += handle -> fileHandle 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) diff --git a/src/main/scala/li/cil/oc/server/fs/ReadOnlyWrapper.scala b/src/main/scala/li/cil/oc/server/fs/ReadOnlyWrapper.scala index 8b8be08c5..f5f7783c4 100644 --- a/src/main/scala/li/cil/oc/server/fs/ReadOnlyWrapper.scala +++ b/src/main/scala/li/cil/oc/server/fs/ReadOnlyWrapper.scala @@ -33,8 +33,8 @@ private class ReadOnlyWrapper(val fileSystem: api.fs.FileSystem) extends api.fs. override def open(path: String, mode: Mode) = mode match { case Mode.Read => fileSystem.open(path, mode) - case Mode.Write => throw new FileNotFoundException() - case Mode.Append => throw new FileNotFoundException() + case Mode.Write => throw new FileNotFoundException("Read-only filesystem; cannot open for writing: " + path) + case Mode.Append => throw new FileNotFoundException("Read-only filesystem; cannot open for appending: " + path) } override def getHandle(handle: Int) = fileSystem.getHandle(handle) diff --git a/src/main/scala/li/cil/oc/server/fs/VirtualFileSystem.scala b/src/main/scala/li/cil/oc/server/fs/VirtualFileSystem.scala index 21deb7fa0..7319faee5 100644 --- a/src/main/scala/li/cil/oc/server/fs/VirtualFileSystem.scala +++ b/src/main/scala/li/cil/oc/server/fs/VirtualFileSystem.scala @@ -67,7 +67,7 @@ trait VirtualFileSystem extends OutputStreamFileSystem { } 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)) { val segmentsTo = segments(to) root.get(segmentsTo.dropRight(1)) match {