@Test void findBaseDir() throws IOException { File tmpDir = Files.createTempDirectory("projectforge-application-basedir-test").toFile(); File pfDir = new File(tmpDir, "ProjectForge"); pfDir.mkdir(); File subDir = new File(pfDir, "subdir"); subDir.mkdir(); File dir = ProjectForgeHomeFinder.findBaseDirAndAncestors(subDir); assertEquals("ProjectForge", dir.getName()); dir = ProjectForgeHomeFinder.findBaseDirAndAncestors(new File(".")); if (dir != null) assertFalse(new File(dir, "projectforge-business").exists(), "The source code directory shouldn't be found."); }
static File findBaseDirAndAncestors(File baseDir) { if (baseDir == null) return null; File currentDir = CanonicalFileUtils.absolute(baseDir); int recursiveCounter = 100; do { File dir = findBaseDirOnly(currentDir); if (dir != null) { return dir; } currentDir = currentDir.getParentFile(); } while (currentDir != null && --recursiveCounter > 0); return null; }
ProjectForgeHomeFinder { static File findBaseDirAndAncestors(File baseDir) { if (baseDir == null) return null; File currentDir = CanonicalFileUtils.absolute(baseDir); int recursiveCounter = 100; do { File dir = findBaseDirOnly(currentDir); if (dir != null) { return dir; } currentDir = currentDir.getParentFile(); } while (currentDir != null && --recursiveCounter > 0); return null; } }
ProjectForgeHomeFinder { static File findBaseDirAndAncestors(File baseDir) { if (baseDir == null) return null; File currentDir = CanonicalFileUtils.absolute(baseDir); int recursiveCounter = 100; do { File dir = findBaseDirOnly(currentDir); if (dir != null) { return dir; } currentDir = currentDir.getParentFile(); } while (currentDir != null && --recursiveCounter > 0); return null; }  }
ProjectForgeHomeFinder { static File findBaseDirAndAncestors(File baseDir) { if (baseDir == null) return null; File currentDir = CanonicalFileUtils.absolute(baseDir); int recursiveCounter = 100; do { File dir = findBaseDirOnly(currentDir); if (dir != null) { return dir; } currentDir = currentDir.getParentFile(); } while (currentDir != null && --recursiveCounter > 0); return null; }  static String getHomeEnvironmentVariableDefinition(); static File[] getSuggestedDirectories(); static boolean isStandardProjectForgeUserDir(File dir); static boolean isProjectForgeSourceCodeRepository(File dir); static boolean isProjectForgeConfigured(String dir); static boolean isProjectForgeConfigured(File dir); }
ProjectForgeHomeFinder { static File findBaseDirAndAncestors(File baseDir) { if (baseDir == null) return null; File currentDir = CanonicalFileUtils.absolute(baseDir); int recursiveCounter = 100; do { File dir = findBaseDirOnly(currentDir); if (dir != null) { return dir; } currentDir = currentDir.getParentFile(); } while (currentDir != null && --recursiveCounter > 0); return null; }  static String getHomeEnvironmentVariableDefinition(); static File[] getSuggestedDirectories(); static boolean isStandardProjectForgeUserDir(File dir); static boolean isProjectForgeSourceCodeRepository(File dir); static boolean isProjectForgeConfigured(String dir); static boolean isProjectForgeConfigured(File dir); static final String ENV_PROJECTFORGE_HOME; static final String COMMAND_LINE_VAR_HOME_DIR; }