comparison src/name/blackcap/exifwasher/Files.kt @ 3:19c381c536ec

Code to make it a proper Mac GUI app. Untested!
author David Barts <n5jrn@me.com>
date Wed, 08 Apr 2020 20:29:12 -0700
parents db63d01a23c6
children dc1f4359659d
comparison
equal deleted inserted replaced
2:efd9fe2d70d7 3:19c381c536ec
60 60
61 private fun File.makeIfNeeded() = if (exists()) { true } else { mkdirs() } 61 private fun File.makeIfNeeded() = if (exists()) { true } else { mkdirs() }
62 62
63 /* make some usable objects */ 63 /* make some usable objects */
64 64
65 val CHARSET = "UTF-8"
66
65 val DPROPERTIES = Properties().apply { 67 val DPROPERTIES = Properties().apply {
66 OS::class.java.getResourceAsStream("default.properties").use { load(it) } 68 OS::class.java.getResourceAsStream("default.properties").use { load(it) }
67 } 69 }
68 70
69 val PROPERTIES = Properties(DPROPERTIES).apply { 71 val PROPERTIES = Properties(DPROPERTIES).apply {
70 PF_DIR.makeIfNeeded() 72 PF_DIR.makeIfNeeded()
71 PROP_FILE.createNewFile() 73 PROP_FILE.createNewFile()
72 BufferedReader(InputStreamReader(FileInputStream(PROP_FILE), "UTF-8")).use { 74 BufferedReader(InputStreamReader(FileInputStream(PROP_FILE), CHARSET)).use {
73 load(it) 75 load(it)
74 } 76 }
75 } 77 }
76 78
79 System.setProperty("java.util.logging.SimpleFormatter.format",
80 "%1$tFT%1$tT%1$tz %2$s%n%4$s: %5$s%6$s%n")
77 val LOGGER = run { 81 val LOGGER = run {
78 LF_DIR.makeIfNeeded() 82 LF_DIR.makeIfNeeded()
79 Logger.getLogger(LONGNAME).apply { 83 Logger.getLogger(LONGNAME).apply {
80 addHandler(FileHandler(LOG_FILE.toString()).apply { 84 addHandler(FileHandler(LOG_FILE.toString()).apply {
81 formatter = SimpleFormatter() }) 85 formatter = SimpleFormatter() })