blob: 19e2513bc2186bd0a71f3f0fd46b6c1e0bf7267c [file] [log] [blame] [raw]
package li.cil.oc.server.fs
import java.io
import java.io.FileInputStream
class ReadOnlyFileSystem(val root: io.File) extends InputStreamFileSystem {
def exists(path: String) = new io.File(root, path).exists()
def size(path: String) = new io.File(root, path).length()
def isDirectory(path: String) = new io.File(root, path).isDirectory
def list(path: String) = Some(new io.File(root, path).listFiles().
map(file => if (file.isDirectory) file.getName + "/" else file.getName))
protected def openInputStream(path: String, handle: Long) = Some(new FileInputStream(new io.File(root, path)))
}