@Test public void testConfigHelperFindLocalDirInPathNotExistent() throws IOException { File startingPath = EnvironmentUtil.isWindows() ? new File("C:\\does\\not\\exist") : new File("/does/not/exist"); File actualLocalDir = ConfigHelper.findLocalDirInPath(startingPath); assertNull(actualLocalDir); }
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);  }