Mercurial > cgi-bin > hgweb.cgi > ImagePrep
comparison src/name/blackcap/imageprep/Settings.kt @ 5:884f1415a330
Rationalized directory management.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 17 Jul 2020 17:11:43 -0700 |
parents | 5234e4500d45 |
children |
comparison
equal
deleted
inserted
replaced
4:5234e4500d45 | 5:884f1415a330 |
---|---|
7 | 7 |
8 /* work around name shadowing */ | 8 /* work around name shadowing */ |
9 private val _PROPS = PROPERTIES | 9 private val _PROPS = PROPERTIES |
10 | 10 |
11 object Settings { | 11 object Settings { |
12 private val homeDir = System.getProperty("user.home") | |
13 var maxDimension = _PROPS.getProperty("maxDimension").toInt() | 12 var maxDimension = _PROPS.getProperty("maxDimension").toInt() |
14 var outputQuality = _PROPS.getProperty("outputQuality").toInt() | 13 var outputQuality = _PROPS.getProperty("outputQuality").toInt() |
15 var outputSuffix = _PROPS.getProperty("outputSuffix") | 14 var outputSuffix = _PROPS.getProperty("outputSuffix") |
16 var outputTo = tilde(_PROPS.getProperty("outputTo")) | 15 var outputTo = tilde(_PROPS.getProperty("outputTo")) |
17 var outputToInputDir = strToBool(_PROPS.getProperty("outputToInputDir")) | 16 var outputToInputDir = strToBool(_PROPS.getProperty("outputToInputDir")) |
18 | |
19 private fun tilde(s: String?): String { | |
20 if (s.isNullOrEmpty()) | |
21 return homeDir | |
22 if (s.startsWith("~/") || s.startsWith("~\\")) | |
23 return File(homeDir, s.substring(2).trimStart(s[1])).toString() | |
24 else | |
25 return s | |
26 } | |
27 | 17 |
28 private fun strToBool(s: String): Boolean { | 18 private fun strToBool(s: String): Boolean { |
29 if (s.isNullOrEmpty()) | 19 if (s.isNullOrEmpty()) |
30 return false | 20 return false |
31 val c1 = s[0].toLowerCase() | 21 val c1 = s[0].toLowerCase() |