diff options
author | Haoyi Li <haoyi@haoyi-mbp.corp.dropbox.com> | 2014-11-26 00:45:31 -0800 |
---|---|---|
committer | Haoyi Li <haoyi@haoyi-mbp.corp.dropbox.com> | 2014-11-26 00:45:31 -0800 |
commit | 24f31e120f9537faede7a174bb09ee35f64e1ce4 (patch) | |
tree | 06ffc3ecc7847789008352b7e2b7c040dad48907 /examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala | |
parent | b89ce9cbf79363f8cab09186a5d7ba94bc0af02a (diff) | |
parent | 2c4b142503bd2d871e6818b5cab8c38627d9e4a0 (diff) | |
download | hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.tar.gz hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.tar.bz2 hands-on-scala-js-24f31e120f9537faede7a174bb09ee35f64e1ce4.zip |
Merge commit '2c4b142503bd2d871e6818b5cab8c38627d9e4a0' as 'examples/scala-js'
Diffstat (limited to 'examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala')
-rw-r--r-- | examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala new file mode 100644 index 0000000..a0dd7a5 --- /dev/null +++ b/examples/scala-js/tools/jvm/src/main/scala/scala/scalajs/tools/classpath/builder/PhysicalFileSystem.scala @@ -0,0 +1,41 @@ +package scala.scalajs.tools.classpath.builder + +import scala.scalajs.tools.io._ + +import scala.collection.immutable.Traversable + +import java.io._ + +/** FileSystem implementation using java.io._ */ +trait PhysicalFileSystem extends FileSystem { + + type File = java.io.File + + val DummyVersion: String = "DUMMY_FILE" + + def isDirectory(f: File): Boolean = f.isDirectory + def isFile(f: File): Boolean = f.isFile + def isJSFile(f: File): Boolean = f.isFile && f.getName.endsWith(".js") + def isIRFile(f: File): Boolean = f.isFile && f.getName.endsWith(".sjsir") + def isJARFile(f: File): Boolean = f.isFile && f.getName.endsWith(".jar") + def exists(f: File): Boolean = f.exists + + def getName(f: File): String = f.getName + def getAbsolutePath(f: File): String = f.getAbsolutePath + def getVersion(f: File): String = f.lastModified.toString + + def listFiles(d: File): Traversable[File] = { + require(d.isDirectory) + Option(d.listFiles).map(_.toList).getOrElse { + throw new IOException(s"Couldn't list files in $d") + } + } + + def toJSFile(f: File): VirtualJSFile = FileVirtualJSFile(f) + def toIRFile(f: File): VirtualScalaJSIRFile = FileVirtualScalaJSIRFile(f) + def toReader(f: File): Reader = + new BufferedReader(new FileReader(f)) + def toInputStream(f: File): InputStream = + new BufferedInputStream(new FileInputStream(f)) + +} |