Added dependency injections for FileUtils and removed redundant code

This commit is contained in:
Ernir Erlingsson
2015-12-10 10:49:28 +01:00
parent fb2a44c478
commit a5fd7ff9dc
12 changed files with 41 additions and 70 deletions

View File

@@ -0,0 +1,25 @@
package org.briarproject.system;
import org.briarproject.api.system.FileUtils;
import java.io.File;
import java.io.IOException;
public class FileUtilsImpl implements FileUtils {
public long getTotalSpace(File f) throws IOException {
return f.getTotalSpace(); // Requires Java 1.6
}
public long getFreeSpace(File f) throws IOException {
return f.getUsableSpace(); // Requires Java 1.6
}
public void deleteFileOrDir(File f) {
if (f.isFile())
f.delete();
else if (f.isDirectory())
for (File child : f.listFiles())
deleteFileOrDir(child);
}
}