class BackupFileVisitor
extends java.lang.Object
implements java.nio.file.FileVisitor<java.nio.file.Path>
FileVisitor
interface.
Takes care of copying and modifying the files in the backup directory according to
their state in the original directory.
Modifier and Type | Field and Description |
---|---|
private BackupInstance |
mBackupInstance |
private java.nio.file.attribute.FileTime |
mDirLastModified |
Constructor and Description |
---|
BackupFileVisitor(BackupInstance instance)
The
BackupFileVisitor constructor. |
Modifier and Type | Method and Description |
---|---|
java.nio.file.FileVisitResult |
postVisitDirectory(java.nio.file.Path dir,
java.io.IOException exc)
Invoked for a directory after entries in the directory, and all of their
descendants, have been visited.
|
java.nio.file.FileVisitResult |
preVisitDirectory(java.nio.file.Path dir,
java.nio.file.attribute.BasicFileAttributes attrs)
Invoked for a directory before entries in the directory are visited.
|
java.nio.file.FileVisitResult |
visitFile(java.nio.file.Path file,
java.nio.file.attribute.BasicFileAttributes attrs)
Invoked for a file in a directory.
|
java.nio.file.FileVisitResult |
visitFileFailed(java.nio.file.Path file,
java.io.IOException exc)
Invoked for a file that could not be visited.
|
private BackupInstance mBackupInstance
private java.nio.file.attribute.FileTime mDirLastModified
BackupFileVisitor(BackupInstance instance)
BackupFileVisitor
constructor.
It takes an instance of BackupInstance
to perform the backup actions.instance
- instance of BackupInstance
to perform the backup actionspublic java.nio.file.FileVisitResult preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException
If this method returns CONTINUE
,
then entries in the directory are visited. If this method returns SKIP_SUBTREE
or SKIP_SIBLINGS
then entries in the
directory (and any descendants) will not be visited.
preVisitDirectory
in interface java.nio.file.FileVisitor<java.nio.file.Path>
dir
- a reference to the directoryattrs
- the directory's basic attributesjava.io.IOException
- if an I/O error occurspublic java.nio.file.FileVisitResult visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException
visitFile
in interface java.nio.file.FileVisitor<java.nio.file.Path>
file
- a reference to the fileattrs
- the file's basic attributesjava.io.IOException
- if an I/O error occurspublic java.nio.file.FileVisitResult visitFileFailed(java.nio.file.Path file, java.io.IOException exc) throws java.io.IOException
visitFileFailed
in interface java.nio.file.FileVisitor<java.nio.file.Path>
file
- a reference to the fileexc
- the I/O exception that prevented the file from being visitedjava.io.IOException
- if an I/O error occurspublic java.nio.file.FileVisitResult postVisitDirectory(java.nio.file.Path dir, java.io.IOException exc) throws java.io.IOException
visitFile
method returning SKIP_SIBLINGS
,
or an I/O error when iterating over the directory).postVisitDirectory
in interface java.nio.file.FileVisitor<java.nio.file.Path>
dir
- a reference to the directoryexc
- null
if the iteration of the directory completes without
an error; otherwise the I/O exception that caused the iteration
of the directory to complete prematurelyjava.io.IOException
- if an I/O error occurs