Class DeletingVisitor
- java.lang.Object
-
- java.nio.file.SimpleFileVisitor<Path>
-
- org.apache.logging.log4j.core.appender.rolling.action.DeletingVisitor
-
- All Implemented Interfaces:
FileVisitor<Path>
public class DeletingVisitor extends SimpleFileVisitor<Path>
FileVisitor that deletes files that are accepted by all PathFilters. Directories are ignored.
-
-
Constructor Summary
Constructors Constructor Description DeletingVisitor(Path basePath, List<? extends PathCondition> pathConditions, boolean testMode)
Constructs a new DeletingVisitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
delete(Path file)
Deletes the specified file.boolean
isTestMode()
Returnstrue
if files are not deleted even when all conditions accept a path,false
otherwise.FileVisitResult
visitFile(Path file, BasicFileAttributes attrs)
-
Methods inherited from class java.nio.file.SimpleFileVisitor
postVisitDirectory, preVisitDirectory, visitFileFailed
-
-
-
-
Constructor Detail
-
DeletingVisitor
public DeletingVisitor(Path basePath, List<? extends PathCondition> pathConditions, boolean testMode)
Constructs a new DeletingVisitor.- Parameters:
basePath
- used to relativize pathspathConditions
- objects that need to confirm whether a file can be deletedtestMode
- if true, files are not deleted but instead a message is printed to the status logger at INFO level. Users can use this to do a dry run to test if their configuration works as expected.
-
-
Method Detail
-
visitFile
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Overrides:
visitFile
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
delete
protected void delete(Path file) throws IOException
Deletes the specified file.- Parameters:
file
- the file to delete- Throws:
IOException
- if a problem occurred deleting the file
-
isTestMode
public boolean isTestMode()
Returnstrue
if files are not deleted even when all conditions accept a path,false
otherwise.- Returns:
true
if files are not deleted even when all conditions accept a path,false
otherwise
-
-