public static File [ ] getEnvironmentPath ( final String toolName , final char switchChar , final String [ ] defaultRelativePath ) { if ( toolName == null ) { throw new NullPointerException ( "toolName" ) ; } if ( defaultRelativePath == null ) { throw new NullPointerException ( "defaultRelativePath" ) ; } String [ ] path = defaultRelativePath ; File exeDir = CUtil . getExecutableLocation ( toolName + ".exe" ) ; if ( exeDir != null ) { final File cfgFile = new File ( exeDir , toolName + ".cfg" ) ; if ( cfgFile . exists ( ) ) { try { final Reader reader = new BufferedReader ( new FileReader ( cfgFile ) ) ; final BorlandCfgParser cfgParser = new BorlandCfgParser ( switchChar ) ; path = cfgParser . parsePath ( reader ) ; reader . close ( ) ; } catch ( final IOException ex ) { // // could be logged // } } } else { // // if can't find the executable, // assume current directory to resolve relative paths // exeDir = new File ( System . getProperty ( "user.dir" ) ) ; } int nonExistant = 0 ; File [ ] resourcePath = new File [ path . length ] ; for ( int i = 0 ; i < path . length ; i ++ ) { resourcePath [ i ] = new File ( path [ i ] ) ; if ( ! resourcePath [ i ] . isAbsolute ( ) ) { resourcePath [ i ] = new File ( exeDir , path [ i ] ) ; } // // if any of the entries do not exist or are // not directories, null them out if ( ! ( resourcePath [ i ] . exists ( ) && resourcePath [ i ] . isDirectory ( ) ) ) { resourcePath [ i ] = null ; nonExistant ++ ; } } // // if there were some non-existant or non-directory // entries in the configuration file then // create a shorter array if ( nonExistant > 0 ) { final File [ ] culled = new File [ resourcePath . length - nonExistant ] ; int index = 0 ; for ( final File element : resourcePath ) { if ( element != null ) { culled [ index ++ ] = element ; } } resourcePath = culled ; } return resourcePath ; }
This method extracts path information from the appropriate . cfg file in the install directory .