Class SFtpDir
- All Implemented Interfaces:
AutoCloseable
Inspect, sort, and iterate an SFTP directory listing.
Chilkat.SFtpDir represents a directory listing returned by an
SFTP operation. It provides the original path used to fetch the listing, the
number of files and subdirectories found, methods for retrieving filenames
or full SFtpFile entry details by index, sorting support, and a
way to load a completed asynchronous directory-listing result.
Directory listing object
Holds the files and subdirectories returned from an SFTP directory-read operation.
Original path tracking
Use OriginalPath to see the remote path that was requested
when the directory listing was created.
Entry count
Read NumFilesAndDirs to determine how many directory
entries are available for iteration.
Filename access
Use GetFilename to retrieve the name of an entry by
zero-based index.
Full entry details
Use FileAt to populate an SFtpFile object with
metadata for a selected file or subdirectory.
Sorting and async results
Sort entries by filename, timestamps, or size, and load directory listings returned from completed async tasks.
Common pattern:
Use a Chilkat.SFtp object to open or read a remote directory,
then use the returned SFtpDir object to inspect
NumFilesAndDirs, optionally call Sort, and loop
from index 0 through the final entry. Use
GetFilename when only names are needed, or FileAt
when the application needs the full SFtpFile metadata for each
entry.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCopies the metadata for the directory entry at the zero-basedindexintofileObj.getFilename(int index)Returns the filename of the directory entry at the zero-basedindex.intReturns the number of entries in this directory listing.Returns the original remote path used to create this directory listing.voidReorders the files and subdirectories in this listing according tofield.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
SFtpDir
public SFtpDir()Creates a newSFtpDirobject.
-
-
Method Details
-
getNumFilesAndDirs
public int getNumFilesAndDirs()Returns the number of entries in this directory listing.The count includes every item returned by the server, such as regular files, directories, symbolic links, and special entries. Valid zero-based indexes range from
0throughNumFilesAndDirs - 1.- Returns:
- the value of the
NumFilesAndDirsproperty (read-only)
-
getOriginalPath
Returns the original remote path used to create this directory listing.This is the same path string that was supplied to the SFTP directory-open operation. It identifies the requested directory and is retained with the listing for later reference.
- Returns:
- the value of the
OriginalPathproperty (read-only)
-
fileAt
Copies the metadata for the directory entry at the zero-basedindexintofileObj.The first entry is at index
0. Useto determine the number of available entries.getNumFilesAndDirs()The populated
SFtpFileobject provides the entry name, type, size, timestamps, ownership, permissions, and any additional attributes supplied by the SFTP server.Use
when only the entry name is needed.getFilename(int)- Parameters:
index- theindexargumentfileObj- thefileObjargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getFilename
Returns the filename of the directory entry at the zero-basedindex.The first entry is at index
0. Useto determine the number of available entries.getNumFilesAndDirs()Use
when the application needs the fullfileAt(int, SFtpFile)SFtpFilemetadata rather than only the entry name.- Parameters:
index- theindexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sort
Reorders the files and subdirectories in this listing according tofield.Set
ascendingtotruefor ascending order orfalsefor descending order. The new order is used by index-based methods such asandgetFilename(int).fileAt(int, SFtpFile)field Sort key
filenameFilename using the normal case-sensitive comparison.filenameNoCaseFilename using a case-insensitive comparison.lastModifiedTimeLast-modified date and time.lastAccessTimeLast-access date and time.lastCreateTimeCreation date and time.sizeEntry size in bytes.- Parameters:
field- thefieldargument (notnull)ascending- theascendingargument
-