From 95d627ef594d44c18fddc6556916720c5578bac2 Mon Sep 17 00:00:00 2001 From: michelou Date: Fri, 11 May 2007 13:16:31 +0000 Subject: added property file to scala-library.jar --- src/library/scala/runtime/Properties.scala | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/library/scala/runtime/Properties.scala (limited to 'src/library') diff --git a/src/library/scala/runtime/Properties.scala b/src/library/scala/runtime/Properties.scala new file mode 100644 index 0000000000..3e46646f2b --- /dev/null +++ b/src/library/scala/runtime/Properties.scala @@ -0,0 +1,57 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala.runtime + +/** A utility to load the library properties from a Java properties file + * included in the jar. + * + * @author Stephane Micheloud + */ +object Properties { + + /** The name of the properties file */ + private val propFilename = "/library.properties" + + /** The loaded properties */ + private val props = { + val props = new java.util.Properties + val stream = classOf[Application].getResourceAsStream(propFilename) + if (stream != null) + props.load(stream) + props + } + + /** The version number of the jar this was loaded from, or + * "(unknown)" if it cannot be determined. + */ + val versionString: String = { + val defaultString = "(unknown)" + "version " + props.getProperty("version.number") + } + + val copyrightString: String = { + val defaultString = "(c) 2002-2007 LAMP/EPFL" + props.getProperty("copyright.string", defaultString) + } + + val encodingString: String = { + val defaultString = "ISO-8859-1" + props.getProperty("file.encoding", defaultString) + } + + private val writer = new java.io.PrintWriter(Console.err, true) + + val versionMsg = "Scala library " + versionString + " -- " + copyrightString + + def main(args: Array[String]) { + writer.println(versionMsg) + } +} -- cgit v1.2.3