SFtpFile Chilkat2 Perl Reference Documentation
Chilkat2::SFtpFile
Current Version: 11.7.0
Markdown version of this page for AI tools (v 11.7.0) · all AI docs
Chilkat.SFtpFile
Read
Access the entry size as a 32-bit integer, 64-bit integer, or decimal
string using
Inspect creation, last-access, and last-modified times as date/time
values or RFC822-formatted strings when supported by the server.
Read numeric user and group IDs, and when the server supports it, textual
owner and group names.
Inspect the POSIX-style permissions bit mask for read, write, execute,
set-user-ID, set-group-ID, and sticky-bit information.
Check server-provided flags such as hidden, read-only, archive,
immutable, encrypted, compressed, sparse, append-only, system, and sync.
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
Filename and FileType, or use convenience
flags such as IsRegular, IsDirectory, and
IsSymLink.
File sizes
Size32, Size64, or
SizeStr.
Timestamps
Ownership
Permissions
Extended attributes
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.
Object Creation
use Chilkat2;
my $sFtpFile = Chilkat2::SFtpFile->new;
# or set properties (and RaiseError) at creation:
# my $sFtpFile = Chilkat2::SFtpFile->new(VerboseLogging => 1, RaiseError => 1);Creates the object. The optional pairs set writable properties (and RaiseError) in order, as if set one by one; an unknown or read-only name croaks. use Chilkat2; loads every class; the Chilkat2/SFtpFile.pm file holds only this class's documentation (perldoc Chilkat2::SFtpFile).
Perl frees the object when its last reference goes (undef $sFtpFile, or the variable going out of scope); there is nothing to close. Objects returned by methods are independent and freed the same way. The class may be subclassed (use parent -norequire, 'Chilkat2::SFtpFile';): an object is a blessed hash reference whose hash is free for the subclass's own fields.
When false (the default), a method that fails returns false (or undef), and the reason is in LastErrorText. When true, it dies with a Chilkat2::Error instead, as DBI does with its RaiseError. Objects returned by a method inherit the value of the object that returned them.
Errors
A Chilkat2::Error stringifies to the failed call's full LastErrorText, and has the methods text, class ('Chilkat2::SFtpFile'), method (the method name) and object. Methods that look something up and find nothing return undef without dying (each such method says so), methods that answer a question (HasMember, IsUnlocked, ...) return a plain boolean, and property reads and writes never fail for Chilkat reasons.
Misuse always croaks, with your file and line, whatever RaiseError is: a wrong number of arguments, a reference or undef where a string or number is expected, an object of the wrong class, an out-of-range integer, a string containing a NUL character, a wide character in a byte string, or a write to a read-only property.
Strings are Perl character strings in both directions (length, regexes and :encoding layers see characters); binary data (BinData) is a byte string. Unlocking: call Chilkat2::Global->new->UnlockBundle('...') once at startup.
Properties
CreateTimeStr
my $strVal = $sFtpFile->CreateTimeStr;
Returns the file creation date and time as an RFC 822-formatted string, such as Fri, 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.
topDebugLogFilePath
my $strVal = $sFtpFile->DebugLogFilePath;
$sFtpFile->DebugLogFilePath($strVal);
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
Filename
my $strVal = $sFtpFile->Filename;
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.
topFileType
my $strVal = $sFtpFile->FileType;
Identifies the type of directory entry. The returned value is one of the following:
| Value | Meaning |
|---|---|
regular | A regular file. |
directory | A directory. |
symLink | A symbolic link. |
special | A special file whose more specific type is not reported. |
unknown | The type is unknown or was not provided by the server. |
socket | A socket. |
charDevice | A character device. |
blockDevice | A block device. |
fifo | A FIFO (named pipe). |
The convenience properties IsRegular, IsDirectory, and IsSymLink may be used for the most common entry types.
Gid
my $intVal = $sFtpFile->Gid;
Returns the numeric group ID associated with the file.
topGroup
my $strVal = $sFtpFile->Group;
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.
topIsAppendOnly
my $boolVal = $sFtpFile->IsAppendOnly;
Returns 1 if 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.
topIsArchive
my $boolVal = $sFtpFile->IsArchive;
Returns 1 if the server marks the file for inclusion in backup or archive operations.
Server requirement: This attribute is defined for SFTP version 6 or later.
topIsCaseInsensitive
my $boolVal = $sFtpFile->IsCaseInsensitive;
Applies to directories. Returns 1 when names within the directory should be compared without regard to letter case.
Server requirement: This attribute is defined for SFTP version 6 or later.
topIsCompressed
my $boolVal = $sFtpFile->IsCompressed;
Returns 1 if 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.
topIsDirectory
my $boolVal = $sFtpFile->IsDirectory;
Returns 1 if the directory entry is a directory.
IsEncrypted
my $boolVal = $sFtpFile->IsEncrypted;
Returns 1 if 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.
topIsHidden
my $boolVal = $sFtpFile->IsHidden;
Returns 1 if the server marks the entry as hidden. Hidden entries are normally omitted from user-facing displays unless the user specifically requests them.
IsImmutable
my $boolVal = $sFtpFile->IsImmutable;
Returns 1 if 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.
topIsReadOnly
my $boolVal = $sFtpFile->IsReadOnly;
Returns 1 if the server marks the file as read-only.
Server requirement: This attribute is defined for SFTP version 6 or later.
topIsRegular
my $boolVal = $sFtpFile->IsRegular;
Returns 1 if the directory entry is a regular file rather than a directory, symbolic link, device, socket, FIFO, or other special type.
IsSparse
my $boolVal = $sFtpFile->IsSparse;
Returns 1 if 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 0.
Server requirement: This attribute is defined for SFTP version 6 or later.
topIsSymLink
my $boolVal = $sFtpFile->IsSymLink;
Returns 1 if the directory entry is a symbolic link.
IsSync
my $boolVal = $sFtpFile->IsSync;
Returns 1 if modifications to the file are committed synchronously to server storage.
Server requirement: This attribute is defined for SFTP version 6 or later.
topIsSystem
my $boolVal = $sFtpFile->IsSystem;
Returns 1 if the server marks the file as part of the operating system.
Server requirement: This attribute is defined for SFTP version 6 or later.
topLastAccessTimeStr
my $strVal = $sFtpFile->LastAccessTimeStr;
Returns the file's last-access date and time as an RFC 822-formatted string, such as Fri, 21 Nov 1997 09:55:06 -0600.
LastErrorHtml
my $strVal = $sFtpFile->LastErrorHtml;
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
my $strVal = $sFtpFile->LastErrorText;
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
my $strVal = $sFtpFile->LastErrorXml;
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
my $boolVal = $sFtpFile->LastMethodSuccess;
$sFtpFile->LastMethodSuccess($boolVal);
Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
LastModifiedTimeStr
my $strVal = $sFtpFile->LastModifiedTimeStr;
Returns the file's last-modified date and time as an RFC 822-formatted string, such as Fri, 21 Nov 1997 09:55:06 -0600.
Use LastModifiedTime when a native date/time value is more convenient.
Owner
my $strVal = $sFtpFile->Owner;
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.
topPermissions
my $intVal = $sFtpFile->Permissions;
Returns the POSIX-style file-permission bit mask. The values correspond to the permission and special-mode bits in the POSIX st_mode field.
| Symbol | Octal value | Meaning |
|---|---|---|
S_IRUSR | 0400 | Owner read |
S_IWUSR | 0200 | Owner write |
S_IXUSR | 0100 | Owner execute |
S_IRGRP | 0040 | Group read |
S_IWGRP | 0020 | Group write |
S_IXGRP | 0010 | Group execute |
S_IROTH | 0004 | Others read |
S_IWOTH | 0002 | Others write |
S_IXOTH | 0001 | Others execute |
S_ISUID | 4000 | Set-user-ID |
S_ISGID | 2000 | Set-group-ID |
S_ISVTX | 1000 | Sticky bit |
Use bitwise AND operations to test individual permission bits.
topSize32
my $intVal = $sFtpFile->Size32;
Returns the file size in bytes as a 32-bit integer. Returns -1 when the size cannot be represented by a 32-bit integer. Use Size64 or SizeStr for larger values.
Size64
my $intVal = $sFtpFile->Size64;
Returns the file size in bytes as a 64-bit integer.
topSizeStr
my $strVal = $sFtpFile->SizeStr;
Returns the file size in bytes as a base-10 string. This is the string representation of Size64 and is useful in environments where a 64-bit integer is inconvenient or unavailable.
Uid
my $intVal = $sFtpFile->Uid;
Returns the numeric user ID associated with the file.
topVerboseLogging
my $boolVal = $sFtpFile->VerboseLogging;
$sFtpFile->VerboseLogging($boolVal);
If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
my $strVal = $sFtpFile->Version;