return new File(file, getFileName(id));
}
+ /**
+ * Removes the file and all its directories, up to the
+ * {@link #dataDirectory}.
+ *
+ * @param id
+ * The ID of the file to remove
+ */
+ public void removeFile(String id) {
+ File file = getFile(id);
+ if (file.delete()) {
+ File parentDirectory = file.getParentFile();
+ String lastDirectory = new File(dataDirectory).getAbsolutePath();
+ while (!lastDirectory.equals(parentDirectory.getAbsolutePath()) && (parentDirectory.listFiles().length == 0)) {
+ parentDirectory.delete();
+ parentDirectory = parentDirectory.getParentFile();
+ }
+ }
+ }
+
//
// PRIVATE METHODS
//