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 classThe 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 StringcreateRelativePath(String parent, String name) 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) voidsetBasedir(String basedir) voidsetIncludes(Collection<String> includes) voidsetSeparator(String separator) Methods inherited from class org.apache.sshd.common.util.io.PathScanningMatcher
couldHoldIncluded, getIncludes, isCaseSensitive, isIncluded, normalizePattern, setCaseSensitive, setIncludes
-
Field Details
-
basedir
-
-
Constructor Details
-
SftpClientDirectoryScanner
public SftpClientDirectoryScanner() -
SftpClientDirectoryScanner
public SftpClientDirectoryScanner(boolean caseSensitive) -
SftpClientDirectoryScanner
-
SftpClientDirectoryScanner
-
SftpClientDirectoryScanner
-
-
Method Details
-
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:
getSeparatorin classPathScanningMatcher- Returns:
- The file separator to use to parse paths - default=local O/S separator
-
setSeparator
- Overrides:
setSeparatorin classPathScanningMatcher
-
setIncludes
- Overrides:
setIncludesin classPathScanningMatcher
-
scan
public Collection<SftpClientDirectoryScanner.ScanDirEntry> scan(SftpClient client) throws IOException, IllegalStateException Scans the currentbasedir- Parameters:
client- TheSftpClientinstance to use- Returns:
- A
CollectionofSftpClientDirectoryScanner.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:
IOExceptionIllegalStateException
-
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- TheSftpClientinstance 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)CollectionofSftpClientDirectoryScanner.ScanDirEntry-ies to update- Returns:
- The updated
CollectionofSftpClientDirectoryScanner.ScanDirEntry-ies - Throws:
IOException- If failed to access remote file system
-
createRelativePath
-