An error occurred while loading the file. Please try again.
-
Lückemeyer authored
Initial commit of the backend for the fork of the Moodle Dockerized Test Agent (MoDTA) from the Moodle Dockerized Test Tool (MoodleDTT)
5372c0e5
package de.hftstuttgart.dtabackend.utils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* Helper Class for all file related tasks.
*
* Created by Marcel Bochtler on 05.01.17.
*/
public class FileUtil {
/**
* Delete the folder and all containing files.
* @param folder Folder to delete
*/
public static void deleteFolderRecursively(File folder) {
File[] files = folder.listFiles();
if (files != null) {
for (File f : files) {
if (f.isDirectory()) {
deleteFolderRecursively(f);
} else {
f.delete();
}
}
}
folder.delete();
}
public static void copyFolder(Path src, Path dst) throws IOException {
Files.walk(src)
.forEach(source -> {
try {
Files.copy(source, dst.resolve(src.relativize(source)));
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
});
}
}