Use java system properties to find the user's home directory before looking to ENV properties.
This commit is contained in:
		@@ -151,8 +151,13 @@ Configuration:
 | 
				
			|||||||
        if (!cfgFile || !cfgFile.exists() || !cfgFile.isFile())
 | 
					        if (!cfgFile || !cfgFile.exists() || !cfgFile.isFile())
 | 
				
			||||||
            cfgFile = new File("wdiwtlt.cli.properties")
 | 
					            cfgFile = new File("wdiwtlt.cli.properties")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!cfgFile || !cfgFile.exists() || !cfgFile.isFile())
 | 
					        if (!cfgFile || !cfgFile.exists() || !cfgFile.isFile()) {
 | 
				
			||||||
            cfgFile = new File(System.getenv().HOME, ".wdiwtlt.cli.properties")
 | 
					            String userHome = System.getenv().HOME
 | 
				
			||||||
 | 
					            if (userHome) cfgFile = new File(userHome, ".wdiwtlt.cli.properties")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!cfgFile || !cfgFile.exists() || !cfgFile.isFile()) {
 | 
				
			||||||
 | 
					              userHome = System.getProperty('user.home')
 | 
				
			||||||
 | 
					              if (userHome) cfgFile = new File(userHome, 'wdiwtlt.cli.properties') } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (cfgFile.exists() && cfgFile.isFile()) {
 | 
					        if (cfgFile.exists() && cfgFile.isFile()) {
 | 
				
			||||||
            try { cfgFile.withInputStream { givenCfg.load(it) } }
 | 
					            try { cfgFile.withInputStream { givenCfg.load(it) } }
 | 
				
			||||||
@@ -273,6 +278,9 @@ Configuration:
 | 
				
			|||||||
        // Try to discover the VLC native libraries
 | 
					        // Try to discover the VLC native libraries
 | 
				
			||||||
        def vlcj
 | 
					        def vlcj
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            String vlcLibDir = opts['--vlc-lib-dir'] || givenCfg['vlc.lib.dir']
 | 
				
			||||||
 | 
					            //if (vlcLibDir) NativeLibrary.addSearchPath('libvlc', vlcLibDir)
 | 
				
			||||||
            new NativeDiscovery().discover()
 | 
					            new NativeDiscovery().discover()
 | 
				
			||||||
            vlcj = new AudioMediaListPlayerComponent() }
 | 
					            vlcj = new AudioMediaListPlayerComponent() }
 | 
				
			||||||
        catch (Exception e) {
 | 
					        catch (Exception e) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,10 +12,15 @@ public class ConfigWrapper {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public ConfigWrapper() {
 | 
					    public ConfigWrapper() {
 | 
				
			||||||
        if (env.WDIWTLT_CONFIG_FILE) {
 | 
					        if (env.WDIWTLT_CONFIG_FILE) {
 | 
				
			||||||
            if (tryLoadConfigFile(new File(env.WDIWTLT_CONFIG_FILE))) {
 | 
					            if (tryLoadConfigFile(env.WDIWTLT_CONFIG_FILE)) {
 | 
				
			||||||
                return } }
 | 
					                return } }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (tryLoadConfigFile(new File(env.HOME, ".wdiwtlt.properties"))) return
 | 
					        if (env.HOME &&
 | 
				
			||||||
 | 
					            tryLoadConfigFile(new File(env.HOME, ".wdiwtlt.properties"))) return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String userHome = System.getProperty('user.home')
 | 
				
			||||||
 | 
					        if (userHome &&
 | 
				
			||||||
 | 
					            tryLoadConfigFile(new File(userHome, '.wdiwtlt.properties'))) return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            ConfigWrapper.getResourceAsStream("/com/jdbernard/wdiwtlt/db/default.properties")
 | 
					            ConfigWrapper.getResourceAsStream("/com/jdbernard/wdiwtlt/db/default.properties")
 | 
				
			||||||
@@ -68,6 +73,10 @@ public class ConfigWrapper {
 | 
				
			|||||||
        if (props) return new HikariConfig(props)
 | 
					        if (props) return new HikariConfig(props)
 | 
				
			||||||
        else return null }
 | 
					        else return null }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private boolean tryLoadConfigFile(String configFilePath) {
 | 
				
			||||||
 | 
					      if (!configFilePath) return false
 | 
				
			||||||
 | 
					      return tryLoadConfigFile(new File(configFilePath)) }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean tryLoadConfigFile(File configFile) {
 | 
					    private boolean tryLoadConfigFile(File configFile) {
 | 
				
			||||||
        if (!configFile.exists() || !configFile.isFile()) return false
 | 
					        if (!configFile.exists() || !configFile.isFile()) return false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user