Add filename to FileNotFoundExceptions thrown in various filesystem implementations

This commit is contained in:
Pwootage 2015-12-16 15:24:18 -07:00
parent 214a0c2c30
commit dbdc813fad
7 changed files with 10 additions and 10 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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)
}
// ----------------------------------------------------------------------- //

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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 {