0
|
1 /*
|
|
2 * Our settings. Basically just some parsed properties.
|
|
3 */
|
|
4 package name.blackcap.imageprep
|
|
5
|
1
|
6 import java.io.File
|
|
7
|
0
|
8 /* work around name shadowing */
|
|
9 private val _PROPS = PROPERTIES
|
|
10
|
|
11 object Settings {
|
2
|
12 private val homeDir = System.getProperty("user.home")
|
0
|
13 val maxDimension = _PROPS.getProperty("maxDimension").toInt()
|
|
14 val outputQuality = _PROPS.getProperty("outputQuality").toInt()
|
2
|
15 val outputSuffix = _PROPS.getProperty("outputSuffix")
|
0
|
16 val outputTo = tilde(_PROPS.getProperty("outputTo"))
|
|
17 val outputToInputDir = strToBool(_PROPS.getProperty("outputToInputDir"))
|
|
18
|
2
|
19 private fun tilde(s: String?): String {
|
0
|
20 if (s.isNullOrEmpty())
|
|
21 return homeDir
|
|
22 if (s.startsWith("~/") || s.startsWith("~\\"))
|
1
|
23 return File(homeDir, s.substring(2).trimStart(s[1])).toString()
|
0
|
24 else
|
|
25 return s
|
|
26 }
|
|
27
|
|
28 private fun strToBool(s: String): Boolean {
|
|
29 if (s.isNullOrEmpty())
|
|
30 return false
|
|
31 val c1 = s[0].toLowerCase()
|
|
32 return c1 == 't' || c1 == 'y'
|
|
33 }
|
|
34 }
|