--- a/src/main/scala/Util.scala Fri Aug 26 01:13:58 2011 -0400
+++ b/src/main/scala/Util.scala Fri Aug 26 10:04:06 2011 -0400
@@ -53,18 +53,24 @@
*
* @return the file on disk
*/
- def fromClasspath(path:String):File = {
- val dir = new File(System.getProperty("java.io.tmpdir"),
- "virtual-trainer-" + scala.util.Random.nextInt(10000).toString)
- if (! dir.mkdir()) logger.error("Couldn't extract %s from jar to %s" format (path, dir.getAbsolutePath))
- val entries = getResourceListing(path) foreach { entry =>
- val url = classloader.getResource(path + entry)
- val content = Source.fromURL(url, "UTF-8").getLines.mkString("\n")
- val writer = new FileWriter(new File(dir, entry))
- writer.write(content)
- writer.close()
+ def fromClasspath(path:String, base:File = new File("src/main/resources")):File = {
+ val workingPath = new File(base, path)
+ if (workingPath isDirectory) {
+ workingPath
+ } else {
+ val dir = new File(System.getProperty("java.io.tmpdir"),
+ "virtual-trainer-" + scala.util.Random.nextInt(10000).toString)
+ if (! dir.mkdir()) logger.error("Couldn't extract %s from jar to %s" format (path, dir.getAbsolutePath))
+ val entries = getResourceListing(path) foreach { entry => {
+ val url = classloader.getResource(path + entry)
+ val content = Source.fromURL(url, "UTF-8").getLines.mkString("\n")
+ val writer = new FileWriter(new File(dir, entry))
+ writer.write(content)
+ writer.close()
+ }
}
dir
+ }
}
}