@Test public void testConfigHelperFindLocalDirInPath() throws Exception { Config testConfig = TestConfigUtil.createTestLocalConfig(); File startingPath = testConfig.getLocalDir(); File actualLocalDir = ConfigHelper.findLocalDirInPath(startingPath); assertNotNull(actualLocalDir); assertEquals(testConfig.getLocalDir(), actualLocalDir.getCanonicalFile()); TestConfigUtil.deleteTestLocalConfigAndData(testConfig); }
public static File findLocalDirInPath(File startingPath) { try { File currentSearchFolder = startingPath.getCanonicalFile(); while (currentSearchFolder != null) { File possibleAppDir = new File(currentSearchFolder, Config.DIR_APPLICATION); File possibleConfigFile = new File(possibleAppDir, Config.FILE_CONFIG); if (possibleAppDir.exists() && possibleConfigFile.exists()) { return possibleAppDir.getParentFile().getCanonicalFile(); } currentSearchFolder = currentSearchFolder.getParentFile(); } return null; } catch (IOException e) { throw new RuntimeException("Unable to determine local directory starting from: "+startingPath, e); } }
ConfigHelper { public static File findLocalDirInPath(File startingPath) { try { File currentSearchFolder = startingPath.getCanonicalFile(); while (currentSearchFolder != null) { File possibleAppDir = new File(currentSearchFolder, Config.DIR_APPLICATION); File possibleConfigFile = new File(possibleAppDir, Config.FILE_CONFIG); if (possibleAppDir.exists() && possibleConfigFile.exists()) { return possibleAppDir.getParentFile().getCanonicalFile(); } currentSearchFolder = currentSearchFolder.getParentFile(); } return null; } catch (IOException e) { throw new RuntimeException("Unable to determine local directory starting from: "+startingPath, e); } } }
ConfigHelper { public static File findLocalDirInPath(File startingPath) { try { File currentSearchFolder = startingPath.getCanonicalFile(); while (currentSearchFolder != null) { File possibleAppDir = new File(currentSearchFolder, Config.DIR_APPLICATION); File possibleConfigFile = new File(possibleAppDir, Config.FILE_CONFIG); if (possibleAppDir.exists() && possibleConfigFile.exists()) { return possibleAppDir.getParentFile().getCanonicalFile(); } currentSearchFolder = currentSearchFolder.getParentFile(); } return null; } catch (IOException e) { throw new RuntimeException("Unable to determine local directory starting from: "+startingPath, e); } }  }
ConfigHelper { public static File findLocalDirInPath(File startingPath) { try { File currentSearchFolder = startingPath.getCanonicalFile(); while (currentSearchFolder != null) { File possibleAppDir = new File(currentSearchFolder, Config.DIR_APPLICATION); File possibleConfigFile = new File(possibleAppDir, Config.FILE_CONFIG); if (possibleAppDir.exists() && possibleConfigFile.exists()) { return possibleAppDir.getParentFile().getCanonicalFile(); } currentSearchFolder = currentSearchFolder.getParentFile(); } return null; } catch (IOException e) { throw new RuntimeException("Unable to determine local directory starting from: "+startingPath, e); } }  static Config loadConfig(File localDir); static boolean configExists(File localDir); static ConfigTO loadConfigTO(File localDir); static RepoTO loadRepoTO(File localDir, ConfigTO configTO); static File findLocalDirInPath(File startingPath); }
ConfigHelper { public static File findLocalDirInPath(File startingPath) { try { File currentSearchFolder = startingPath.getCanonicalFile(); while (currentSearchFolder != null) { File possibleAppDir = new File(currentSearchFolder, Config.DIR_APPLICATION); File possibleConfigFile = new File(possibleAppDir, Config.FILE_CONFIG); if (possibleAppDir.exists() && possibleConfigFile.exists()) { return possibleAppDir.getParentFile().getCanonicalFile(); } currentSearchFolder = currentSearchFolder.getParentFile(); } return null; } catch (IOException e) { throw new RuntimeException("Unable to determine local directory starting from: "+startingPath, e); } }  static Config loadConfig(File localDir); static boolean configExists(File localDir); static ConfigTO loadConfigTO(File localDir); static RepoTO loadRepoTO(File localDir, ConfigTO configTO); static File findLocalDirInPath(File startingPath);  }