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 voiddelete(Path file)Deletes the specified file.booleanisTestMode()Returnstrueif files are not deleted even when all conditions accept a path,falseotherwise.FileVisitResultvisitFile(Path file, BasicFileAttributes attrs)FileVisitResultvisitFileFailed(Path file, IOException ioException)-
Methods inherited from class java.nio.file.SimpleFileVisitor
postVisitDirectory, preVisitDirectory
-
-
-
-
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:
visitFilein interfaceFileVisitor<Path>- Overrides:
visitFilein classSimpleFileVisitor<Path>- Throws:
IOException
-
visitFileFailed
public FileVisitResult visitFileFailed(Path file, IOException ioException) throws IOException
- Specified by:
visitFileFailedin interfaceFileVisitor<Path>- Overrides:
visitFileFailedin 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()
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
-
-