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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Pathprivate static final Loggerprivate final List<? extends PathCondition> private final boolean -
Constructor Summary
ConstructorsConstructorDescriptionDeletingVisitor(Path basePath, List<? extends PathCondition> pathConditions, boolean testMode) Constructs a new DeletingVisitor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDeletes the specified file.booleanReturnstrueif files are not deleted even when all conditions accept a path,falseotherwise.visitFile(Path file, BasicFileAttributes attrs) visitFileFailed(Path file, IOException ioException) Methods inherited from class java.nio.file.SimpleFileVisitor
postVisitDirectory, preVisitDirectory
-
Field Details
-
LOGGER
-
basePath
-
testMode
private final boolean testMode -
pathConditions
-
-
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:
visitFilein interfaceFileVisitor<Path>- Overrides:
visitFilein classSimpleFileVisitor<Path>- Throws:
IOException
-
visitFileFailed
- Specified by:
visitFileFailedin interfaceFileVisitor<Path>- Overrides:
visitFileFailedin 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()Returnstrueif files are not deleted even when all conditions accept a path,falseotherwise.- Returns:
trueif files are not deleted even when all conditions accept a path,falseotherwise
-