mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Refactored FileUtils.
Removed methods that are no longer needed for Java 6, moved the remaining method into the utils directory.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package org.briarproject;
|
||||
|
||||
import org.briarproject.api.UniqueId;
|
||||
import org.briarproject.util.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -15,27 +13,13 @@ public class TestUtils {
|
||||
new AtomicInteger((int) (Math.random() * 1000 * 1000));
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static void delete(File f) {
|
||||
if (f.isDirectory()) for (File child : f.listFiles()) delete(child);
|
||||
f.delete();
|
||||
}
|
||||
|
||||
public static void createFile(File f, String s) throws IOException {
|
||||
f.getParentFile().mkdirs();
|
||||
PrintStream out = new PrintStream(new FileOutputStream(f));
|
||||
out.print(s);
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static File getTestDirectory() {
|
||||
int name = nextTestDir.getAndIncrement();
|
||||
File testDir = new File("test.tmp/" + name);
|
||||
return testDir;
|
||||
return new File("test.tmp/" + name);
|
||||
}
|
||||
|
||||
public static void deleteTestDirectory(File testDir) {
|
||||
delete(testDir);
|
||||
FileUtils.deleteFileOrDir(testDir);
|
||||
testDir.getParentFile().delete(); // Delete if empty
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user