ru.yandex.qatools.allure.utils.DeleteVisitor Maven / Gradle / Ivy
package ru.yandex.qatools.allure.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
/**
* The visitor deletes files and directories.
*/
public class DeleteVisitor extends SimpleFileVisitor {
private static final Logger LOGGER = LoggerFactory.getLogger(DeleteVisitor.class);
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
LOGGER.debug("Delete <{}>", file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
LOGGER.debug("Delete <{}>", dir);
return FileVisitResult.CONTINUE;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy