summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/Properties.scala
blob: f2ea31ed5d1f787b1b36a31a264d2cf220f6f7f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* NSC -- new Scala compiler
 * Copyright 2006-2008 LAMP/EPFL
 * @author  Stephane Micheloud
 */

// $Id$

package scala.tools.nsc

/** A utility to load the compiler properties from a Java properties file
 *  included in the jar.
 */
object Properties {

  /** The name of the properties file */
  private val propFilename = "/compiler.properties"

  /** The loaded properties */
  private val props = {
    val props = new java.util.Properties
    val stream = classOf[Global].getResourceAsStream(propFilename)
    if (stream != null)
      props.load(stream)
    props
  }

  val isWin = System.getProperty("os.name") startsWith "Windows"

  /** 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", defaultString)
  }

  val copyrightString: String = {
    val defaultString = "(c) 2002-2008 LAMP/EPFL"
    props.getProperty("copyright.string", defaultString)
  }

  val encodingString: String = {
    val defaultString = "UTF8" //"ISO-8859-1"
    props.getProperty("file.encoding", defaultString)
  }

  val fileEndingString: String = {
    val defaultString = ".scala|.java"
    props.getProperty("file.ending", defaultString)
  }

  val residentPromptString: String = {
    val defaultString = "\nnsc> "
    props.getProperty("resident.prompt", defaultString)
  }

  val shellPromptString: String = {
    val defaultString = "\nscala> "
    props.getProperty("shell.prompt", defaultString)
  }

  val scalaHome: String =
    System.getProperty("scala.home")

  val envClasspath: String =
    System.getProperty("env.classpath")

  val cmdName: String =
    if (isWin) "scala.bat" else "scala"

  val msilILasm: String =
    System.getProperty("msil.ilasm", "")
}