Package org.apache.sshd.sftp.client.fs
Class SftpClientDirectoryScanner
java.lang.Object
org.apache.sshd.common.util.io.PathScanningMatcher
org.apache.sshd.sftp.client.fs.SftpClientDirectoryScanner
Uses an
SftpClient
to scan a directory (possibly recursively) and find files that match a given set of
inclusion patterns.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The result of a scan -
Field Summary
FieldsFields inherited from class org.apache.sshd.common.util.io.PathScanningMatcher
caseSensitive, includePatterns, separator
-
Constructor Summary
ConstructorsConstructorDescriptionSftpClientDirectoryScanner
(boolean caseSensitive) SftpClientDirectoryScanner
(String dir, String... includes) SftpClientDirectoryScanner
(String dir, Collection<String> includes) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
createRelativePath
(String parent, String name) boolean
Tells whether the scanner is set to return only files and links (the default).scan
(SftpClient client) Scans the currentbasedir
<C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>>
Cscan
(SftpClient client, Supplier<? extends C> factory) protected <C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>>
Cscandir
(SftpClient client, String rootDir, String parent, C filesList) void
setBasedir
(String basedir) void
setFilesOnly
(boolean filesOnly) Sets whether the scanner shall return only regular files, links, and subdirectories.void
setIncludes
(Collection<String> includes) void
setSeparator
(String separator) Methods inherited from class org.apache.sshd.common.util.io.PathScanningMatcher
couldHoldIncluded, getIncludes, isCaseSensitive, isIncluded, normalizePattern, setCaseSensitive, setIncludes
-
Field Details
-
basedir
-
filesOnly
private boolean filesOnly
-
-
Constructor Details
-
SftpClientDirectoryScanner
public SftpClientDirectoryScanner() -
SftpClientDirectoryScanner
public SftpClientDirectoryScanner(boolean caseSensitive) -
SftpClientDirectoryScanner
-
SftpClientDirectoryScanner
-
SftpClientDirectoryScanner
-
-
Method Details
-
isFilesOnly
public boolean isFilesOnly()Tells whether the scanner is set to return only files and links (the default).- Returns:
true
if items that are not regular files or subdirectories shall be omitted;false
otherwise
-
setFilesOnly
public void setFilesOnly(boolean filesOnly) Sets whether the scanner shall return only regular files, links, and subdirectories.- Parameters:
filesOnly
- whether to skip all items that are not regular files, links, or subdirectories
-
getBasedir
-
setBasedir
- Parameters:
basedir
- The base directory from which to start scanning. Note: it is converted to its canonical form when scanning. May not benull
/empty
-
getSeparator
- Overrides:
getSeparator
in classPathScanningMatcher
- Returns:
- The file separator to use to parse paths - default=local O/S separator
-
setSeparator
- Overrides:
setSeparator
in classPathScanningMatcher
-
setIncludes
- Overrides:
setIncludes
in classPathScanningMatcher
-
scan
public Collection<SftpClientDirectoryScanner.ScanDirEntry> scan(SftpClient client) throws IOException, IllegalStateException Scans the currentbasedir
- Parameters:
client
- TheSftpClient
instance to use- Returns:
- A
Collection
ofSftpClientDirectoryScanner.ScanDirEntry
-ies matching theinclusion patterns
- Throws:
IOException
- If failed to access the remote file systemIllegalStateException
- If illegal/missing base directory, or missing inclusion patterns, or specified base path is not a directory
-
scan
public <C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>> C scan(SftpClient client, Supplier<? extends C> factory) throws IOException, IllegalStateException - Throws:
IOException
IllegalStateException
-
scandir
protected <C extends Collection<SftpClientDirectoryScanner.ScanDirEntry>> C scandir(SftpClient client, String rootDir, String parent, C filesList) throws IOException - Type Parameters:
C
- Generic collection type- Parameters:
client
- TheSftpClient
instance to userootDir
- The absolute path of the folder to readparent
- The relative parent of the folder to read - may be empty for base directoryfilesList
- The (nevernull
)Collection
ofSftpClientDirectoryScanner.ScanDirEntry
-ies to update- Returns:
- The updated
Collection
ofSftpClientDirectoryScanner.ScanDirEntry
-ies - Throws:
IOException
- If failed to access remote file system
-
createRelativePath
-