Class SFtpFile
- All Implemented Interfaces:
AutoCloseable
Inspect metadata for a file, directory, symlink, or special item in an SFTP listing.
Chilkat.SFtpFile represents one entry returned from an SFTP
directory listing. It exposes the entry name, file type, size, ownership,
permissions, timestamps, and server-provided attribute flags such as hidden,
read-only, archive, immutable, encrypted, compressed, sparse, append-only,
system, and synchronization status. It is typically used together with
Chilkat.SFtpDir when iterating a remote directory and deciding
how each entry should be displayed, filtered, downloaded, skipped, or
processed.
Name and type
Read Filename and FileType, or use convenience
flags such as IsRegular, IsDirectory, and
IsSymLink.
File sizes
Access the entry size as a 32-bit integer, 64-bit integer, or decimal
string using Size32, Size64, or
SizeStr.
Timestamps
Inspect creation, last-access, and last-modified times as date/time values or RFC822-formatted strings when supported by the server.
Ownership
Read numeric user and group IDs, and when the server supports it, textual owner and group names.
Permissions
Inspect the POSIX-style permissions bit mask for read, write, execute, set-user-ID, set-group-ID, and sticky-bit information.
Extended attributes
Check server-provided flags such as hidden, read-only, archive, immutable, encrypted, compressed, sparse, append-only, system, and sync.
Common pattern:
Retrieve a directory listing with Chilkat.SFtp, iterate its
Chilkat.SFtpDir entries, and populate a
Chilkat.SFtpFile object for each item. Use the file type,
timestamps, size, permissions, and attribute flags to decide whether the
entry is a regular file, directory, symlink, or special item and how the
application should handle it.
Server-version note: Some metadata is only available from newer SFTP protocol versions. For example, textual owner/group information and creation time require SFTP v4 or later, while many extended attribute flags such as read-only, archive, immutable, compressed, encrypted, sparse, append-only, and system require SFTP v6 or later.
</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 TypeMethodDescriptionReturns the file creation date and time as an RFC 822-formatted string, such asFri, 21 Nov 1997 09:55:06 -0600.Returns the name of the directory entry.Identifies the type of directory entry.intgetGid()Returns the numeric group ID associated with the file.getGroup()Returns the textual group name associated with the file.booleanReturnstrueif the server marks the file as append-only.booleanReturnstrueif the server marks the file for inclusion in backup or archive operations.booleanApplies to directories.booleanReturnstrueif the file is stored using transparent filesystem-level compression on the server.booleanReturnstrueif the directory entry is a directory.booleanReturnstrueif the file is stored using transparent filesystem-level encryption on the server.booleanReturnstrueif the server marks the entry as hidden.booleanReturnstrueif the server marks the file as immutable.booleanReturnstrueif the server marks the file as read-only.booleanReturnstrueif the directory entry is a regular file rather than a directory, symbolic link, device, socket, FIFO, or other special type.booleanReturnstrueif the server identifies the file as sparse.booleanReturnstrueif the directory entry is a symbolic link.booleanReturnstrueif modifications to the file are committed synchronously to server storage.booleanReturnstrueif the server marks the file as part of the operating system.Returns the file's last-access date and time as an RFC 822-formatted string, such asFri, 21 Nov 1997 09:55:06 -0600.Returns the file's last-modified date and time as an RFC 822-formatted string, such asFri, 21 Nov 1997 09:55:06 -0600.getOwner()Returns the textual owner name associated with the file.intReturns the POSIX-style file-permission bit mask.intReturns the file size in bytes as a 32-bit integer.longReturns the file size in bytes as a 64-bit integer.Returns the file size in bytes as a base-10 string.intgetUid()Returns the numeric user ID associated with the file.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
SFtpFile
public SFtpFile()Creates a newSFtpFileobject.
-
-
Method Details
-
getCreateTimeStr
Returns the file creation date and time as an RFC 822-formatted string, such asFri, 21 Nov 1997 09:55:06 -0600.Server requirement: Creation-time metadata is available only when the server supports SFTP version 4 or later and provides this attribute.
- Returns:
- the value of the
CreateTimeStrproperty (read-only)
-
getFileType
Identifies the type of directory entry. The returned value is one of the following:Value Meaning
regularA regular file.directoryA directory.symLinkA symbolic link.specialA special file whose more specific type is not reported.unknownThe type is unknown or was not provided by the server.socketA socket.charDeviceA character device.blockDeviceA block device.fifoA FIFO (named pipe).The convenience properties
,getIsRegular(), andgetIsDirectory()may be used for the most common entry types.getIsSymLink()- Returns:
- the value of the
FileTypeproperty (read-only)
-
getFilename
Returns the name of the directory entry. Depending on the entry type, this may be a regular filename, directory name, symbolic-link name, or the name of another special filesystem object.- Returns:
- the value of the
Filenameproperty (read-only)
-
getGid
public int getGid()Returns the numeric group ID associated with the file.- Returns:
- the value of the
Gidproperty (read-only)
-
getGroup
Returns the textual group name associated with the file.Server requirement: This attribute is available only when the server supports SFTP version 4 or later and provides owner/group names.
- Returns:
- the value of the
Groupproperty (read-only)
-
getIsAppendOnly
public boolean getIsAppendOnly()Returnstrueif the server marks the file as append-only. New data may be added only at the end of the file; existing data cannot be overwritten through normal file writes.Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsAppendOnlyproperty (read-only)
-
getIsArchive
public boolean getIsArchive()Returnstrueif the server marks the file for inclusion in backup or archive operations.Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsArchiveproperty (read-only)
-
getIsCaseInsensitive
public boolean getIsCaseInsensitive()Applies to directories. Returnstruewhen names within the directory should be compared without regard to letter case.Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsCaseInsensitiveproperty (read-only)
-
getIsCompressed
public boolean getIsCompressed()Returnstrueif the file is stored using transparent filesystem-level compression on the server.This attribute describes how the server stores the file. It does not change the file bytes transferred through SFTP.
Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsCompressedproperty (read-only)
-
getIsDirectory
public boolean getIsDirectory()Returnstrueif the directory entry is a directory.- Returns:
- the value of the
IsDirectoryproperty (read-only)
-
getIsEncrypted
public boolean getIsEncrypted()Returnstrueif the file is stored using transparent filesystem-level encryption on the server.This attribute describes storage at rest. It does not alter the file bytes returned by read operations or accepted by write operations.
Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsEncryptedproperty (read-only)
-
getIsHidden
public boolean getIsHidden()Returnstrueif the server marks the entry as hidden. Hidden entries are normally omitted from user-facing displays unless the user specifically requests them.- Returns:
- the value of the
IsHiddenproperty (read-only)
-
getIsImmutable
public boolean getIsImmutable()Returnstrueif the server marks the file as immutable. An immutable file cannot normally be deleted, renamed, modified, or used as the target of a new hard link.Immutability is generally stronger than read-only status, the ordinary permission mask, or an access-control list. On many systems, only a privileged administrator can set or clear this attribute.
Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsImmutableproperty (read-only)
-
getIsReadOnly
public boolean getIsReadOnly()Returnstrueif the server marks the file as read-only.Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsReadOnlyproperty (read-only)
-
getIsRegular
public boolean getIsRegular()Returnstrueif the directory entry is a regular file rather than a directory, symbolic link, device, socket, FIFO, or other special type.- Returns:
- the value of the
IsRegularproperty (read-only)
-
getIsSparse
public boolean getIsSparse()Returnstrueif the server identifies the file as sparse. A sparse file can contain unwritten regions, often called holes, that read as zero bytes without consuming equivalent physical disk space.For example, writing data at an offset of 10 MB may leave the region between the previous end of file and that offset unallocated on disk.
Some servers store all files sparsely and may always set this flag. Other servers cannot reliably determine whether a file is sparse, so a file may be sparse even when this property is
false.Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsSparseproperty (read-only)
-
getIsSymLink
public boolean getIsSymLink()Returnstrueif the directory entry is a symbolic link.- Returns:
- the value of the
IsSymLinkproperty (read-only)
-
getIsSync
public boolean getIsSync()Returnstrueif modifications to the file are committed synchronously to server storage.Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsSyncproperty (read-only)
-
getIsSystem
public boolean getIsSystem()Returnstrueif the server marks the file as part of the operating system.Server requirement: This attribute is defined for SFTP version 6 or later.
- Returns:
- the value of the
IsSystemproperty (read-only)
-
getLastAccessTimeStr
Returns the file's last-access date and time as an RFC 822-formatted string, such asFri, 21 Nov 1997 09:55:06 -0600.- Returns:
- the value of the
LastAccessTimeStrproperty (read-only)
-
getLastModifiedTimeStr
Returns the file's last-modified date and time as an RFC 822-formatted string, such asFri, 21 Nov 1997 09:55:06 -0600.Use
when a native date/time value is more convenient.LastModifiedTime- Returns:
- the value of the
LastModifiedTimeStrproperty (read-only)
-
getOwner
Returns the textual owner name associated with the file.Server requirement: This attribute is available only when the server supports SFTP version 4 or later and provides owner/group names.
- Returns:
- the value of the
Ownerproperty (read-only)
-
getPermissions
public int getPermissions()Returns the POSIX-style file-permission bit mask. The values correspond to the permission and special-mode bits in the POSIXst_modefield.Symbol Octal value Meaning
S_IRUSR0400Owner readS_IWUSR0200Owner writeS_IXUSR0100Owner executeS_IRGRP0040Group readS_IWGRP0020Group writeS_IXGRP0010Group executeS_IROTH0004Others readS_IWOTH0002Others writeS_IXOTH0001Others executeS_ISUID4000Set-user-IDS_ISGID2000Set-group-IDS_ISVTX1000Sticky bitUse bitwise AND operations to test individual permission bits.
- Returns:
- the value of the
Permissionsproperty (read-only)
-
getSize32
public int getSize32()Returns the file size in bytes as a 32-bit integer. Returns-1when the size cannot be represented by a 32-bit integer. UseorgetSize64()for larger values.getSizeStr()- Returns:
- the value of the
Size32property (read-only)
-
getSize64
public long getSize64()Returns the file size in bytes as a 64-bit integer.- Returns:
- the value of the
Size64property (read-only)
-
getSizeStr
Returns the file size in bytes as a base-10 string. This is the string representation ofand is useful in environments where a 64-bit integer is inconvenient or unavailable.getSize64()- Returns:
- the value of the
SizeStrproperty (read-only)
-
getUid
public int getUid()Returns the numeric user ID associated with the file.- Returns:
- the value of the
Uidproperty (read-only)
-