Class DeletingVisitor
java.lang.Object
java.nio.file.SimpleFileVisitor<Path>
org.apache.logging.log4j.core.appender.rolling.action.DeletingVisitor
- All Implemented Interfaces:
FileVisitor<Path>
FileVisitor that deletes files that are accepted by all PathFilters. Directories are ignored.
-
Constructor Summary
ConstructorDescriptionDeletingVisitor
(Path basePath, List<? extends PathCondition> pathConditions, boolean testMode) Constructs a new DeletingVisitor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Deletes the specified file.boolean
Returnstrue
if files are not deleted even when all conditions accept a path,false
otherwise.visitFile
(Path file, BasicFileAttributes attrs) visitFileFailed
(Path file, IOException ioException) Methods inherited from class java.nio.file.SimpleFileVisitor
postVisitDirectory, preVisitDirectory
-
Constructor Details
-
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 Details
-
visitFile
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Overrides:
visitFile
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
visitFileFailed
- Specified by:
visitFileFailed
in interfaceFileVisitor<Path>
- Overrides:
visitFileFailed
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
delete
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
-