diff src/name/blackcap/imageprep/Misc.kt @ 5:884f1415a330

Rationalized directory management.
author David Barts <n5jrn@me.com>
date Fri, 17 Jul 2020 17:11:43 -0700
parents 0bded24f746e
children 2bb46da74667
line wrap: on
line diff
--- a/src/name/blackcap/imageprep/Misc.kt	Fri Jul 17 14:51:41 2020 -0700
+++ b/src/name/blackcap/imageprep/Misc.kt	Fri Jul 17 17:11:43 2020 -0700
@@ -246,3 +246,13 @@
     JOptionPane.showMessageDialog(parent,
         dmsg, "Error", JOptionPane.ERROR_MESSAGE)
 }
+
+private val homeDir = System.getProperty("user.home")
+fun tilde(s: String?): String {
+    if (s.isNullOrEmpty())
+        return homeDir
+    if (s.startsWith("~/") || s.startsWith("~\\"))
+        return File(homeDir, s.substring(2).trimStart(s[1])).toString()
+    else
+        return s
+}