scala/ScalaBook/chapter-09/src/main/scala/scalabook/file/NativeFS.scala

package scalabook.file

import path.Path
import java.io.{File => JavaFile}

object NativeFS extends VFS[NativeFile] {
  def mkpath(name: String) = Path(name)

  def name = "NativeFS"

  override def newFile(path: Path) = NativeFile(path)

  def resolve(path: Path) = {
    val file = newFile(path)
    if(file.exists)
      Some(file)
    else
      None
  }

  def newTempFile(prefix: String, suffix: String) =
    NativeFile(JavaFile.createTempFile(prefix, suffix))

  def roots = JavaFile.listRoots.map { root => NativeFile(root) } toList

  def container = None
}