if (!basePathFile.exists() || !basePathFile.isDirectory()) {
return null;
}
- ProjectFileImpl rootProjectFile = new ProjectFileImpl(null, "", true, false);
+ ProjectFileImpl rootProjectFile = new ProjectFileImpl(null, "", 0, true, false);
scanDirectory(basePathFile, rootProjectFile);
return rootProjectFile;
}
return;
}
for (File file: directory.listFiles()) {
- ProjectFileImpl projectFileChild = projectFile.addFile(file.getName(), file.isDirectory(), file.isHidden());
+ ProjectFileImpl projectFileChild = projectFile.addFile(file.getName(), file.length(), file.isDirectory(), file.isHidden());
if (file.isDirectory()) {
scanDirectory(file, projectFileChild);
}
/** The name of this project file. */
private final String name;
+ /** The size of the file. */
+ private final long size;
+
/** Whether this project file is a directory. */
private final boolean directory;
* the new project file does not have a parent
* @param name
* The name of the project file
+ * @param size
+ * The size of the file
* @param isDirectory
* <code>true</code> if this project file is a directory,
* <code>false</code> otherwise
* <code>true</code> if this project file is hidden,
* <code>false</code> otherwise
*/
- ProjectFileImpl(ProjectFileImpl parentProjectFile, String name, boolean isDirectory, boolean isHidden) {
+ ProjectFileImpl(ProjectFileImpl parentProjectFile, String name, long size, boolean isDirectory, boolean isHidden) {
this.parentProjectFile = parentProjectFile;
this.name = name;
+ this.size = size;
this.directory = isDirectory;
this.hidden = isHidden;
}
}
/**
+ * {@inheritDoc}
+ */
+ public long getSize() {
+ return size;
+ }
+
+ /**
* @see net.pterodactylus.jsite.project.ProjectFile#getParents()
*/
public List<ProjectFile> getParents() {
*
* @param name
* The name of the file
+ * @param size
+ * The size of the file
* @param isDirectory
* <code>true</code> if the new file is a directory,
* <code>false</code> otherwise
* <code>false</code> otherwise
* @return The created project file
*/
- public ProjectFileImpl addFile(String name, boolean isDirectory, boolean isHidden) {
- ProjectFileImpl newProjectFile = new ProjectFileImpl(this, name, isDirectory, isHidden);
+ public ProjectFileImpl addFile(String name, long size, boolean isDirectory, boolean isHidden) {
+ ProjectFileImpl newProjectFile = new ProjectFileImpl(this, name, size, isDirectory, isHidden);
childProjectFiles.add(newProjectFile);
return newProjectFile;
}