import compbio.engine.client.PathValidator;\r
import compbio.engine.local.ExecutableWrapper;\r
\r
+//@Deprecated\r
+\r
+// TODO\r
+// understand what this class does and why it was set as deprecated ...\r
+// how to check timestamps of files before deleting\r
public class Cleaner {\r
\r
private static final Logger log = Logger.getLogger(Cleaner.class);\r
* \r
* @param workDirectory\r
* @param files\r
- * @return\r
+ * @return This method returns true if all files specified by List files\r
+ * were successfully removed, false otherwise\r
*/\r
public static boolean deleteFiles(ConfiguredExecutable<?> exec) {\r
\r
// Remove process std output and error capture files, do not care\r
// whether succeed or not\r
// as these are only created for local processes, so may not exist\r
- removeFile(exec.getWorkDirectory() + File.separator\r
- + ExecutableWrapper.PROC_OUT_FILE);\r
- removeFile(exec.getWorkDirectory() + File.separator\r
- + ExecutableWrapper.PROC_ERR_FILE);\r
+ removeFile(exec.getWorkDirectory() + File.separator + ExecutableWrapper.PROC_OUT_FILE);\r
+ removeFile(exec.getWorkDirectory() + File.separator + ExecutableWrapper.PROC_ERR_FILE);\r
// Remove the task directory if all files were successfully removed\r
return removeFile(exec.getWorkDirectory());\r
}\r
if (success) {\r
log.trace(type + filename + " was successfully removed");\r
} else {\r
- log\r
- .debug("Could not remove "\r
- + type\r
- + ": "\r
- + filename\r
- + " reportedly created by executable. Insufficient access right?");\r
+ log.debug("Could not remove "\r
+ + type\r
+ + ": "\r
+ + filename\r
+ + " reportedly created by executable. Insufficient access right?");\r
}\r
} else {\r
log.debug("File: " + filename\r
\r
public static boolean deleteAllFiles(String directory) {\r
if (compbio.util.Util.isEmpty(directory)) {\r
- throw new NullPointerException("Direcotry must be provided! ");\r
+ throw new NullPointerException("Directory must be provided! ");\r
}\r
File rootdir = new File(directory);\r
if (!rootdir.exists()) {\r
- log.error("Directory " + directory\r
- + " does not exist. Have been deleted already?");\r
+ log.error("Directory " + directory + " does not exist. Have been deleted already?");\r
return false;\r
}\r
if (!rootdir.isDirectory()) {\r
int deletedCount = 0;\r
for (File f : files) {\r
if (f.isDirectory()) {\r
- log.error("Cannot delete subdirecotries! Skipping...");\r
+ log.error("Cannot delete subdirectories! Skipping...");\r
} else {\r
- boolean deleted = f.delete();\r
- if (deleted) {\r
+ if (f.delete()) {\r
deletedCount++;\r
+ log.debug("file " + f.getName() + " removed");\r
+ } else {\r
+ log.debug("file " + f.getName() + " is not removed");\r
}\r
}\r
+ \r
}\r
+ rootdir.delete();\r
return deletedCount == files.length;\r
}\r
\r
+ public static boolean deleteDirectory(String directory) {\r
+ if (deleteAllFiles (directory)) {\r
+ File rootdir = new File(directory);\r
+ return rootdir.delete();\r
+ }\r
+ return false;\r
+ }\r
+\r
+ \r
}\r