* path. This method is disk-intensive and may take some time on larger
* directories!
*
- * @return The file for the base path
+ * @return The file for the base path, or <code>null</code> if the base
+ * path does not denote an existing directory
*/
public ProjectFile getBaseFile() {
+ File basePathFile = new File(basePath);
+ if (!basePathFile.exists() || !basePathFile.isDirectory()) {
+ return null;
+ }
ProjectFileImpl rootProjectFile = new ProjectFileImpl(null, "", true, false);
- scanDirectory(new File(basePath), rootProjectFile);
+ scanDirectory(basePathFile, rootProjectFile);
return rootProjectFile;
}
}
/**
+ * {@inheritDoc}
+ */
+ /* TODO - caching? */
+ public String getCompletePath() {
+ StringBuilder completePath = new StringBuilder();
+ ProjectFileImpl currentProjectFile = this;
+ do {
+ completePath.insert(0, File.separatorChar).insert(0, this.getName());
+ } while ((currentProjectFile = currentProjectFile.parentProjectFile) != null);
+ return completePath.substring(1);
+ }
+
+ /**
* @see net.pterodactylus.jsite.project.ProjectFile#isFile()
*/
public boolean isFile() {