Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.SFTP.Types

Feature notes: SFTP implementation notes

Classes, interfaces and records

interfaceiFileAttributes

iFileAttributes is the protocol-version-independent view of one file's attributes as carried in SFTP SSH_FXP_ATTRS and SSH_FXP_NAME payloads. It exposes only the fields common to every version -- size, POSIX permissions, access/modify times; call GetFullInterface to reach the v3- or v5-specific members (owner/group, ACL, attribute type). In this codebase it is a client-side abstraction: the SFTP client wraps attributes returned by stat/lstat/readdir in it, or builds one to send in setstat/open/mkdir. The server subsystem uses its own attribute record, not this interface.

function GetAccessTimeAsDateTime: TDateTime;
Getter behind AccessTimeAsDateTime; converts the stored Unix time_t to a TDateTime.
function GetModifyTimeAsDateTime: TDateTime;
Getter behind ModifyTimeAsDateTime; converts the stored Unix seconds to a TDateTime.
procedure SetAccessTimeAsDateTime(const Value: TDateTime);
Setter behind AccessTimeAsDateTime; stores Unix seconds and flags the access-time field present for encoding.
procedure SetModifyTimeAsDateTime(const Value: TDateTime);
Setter behind ModifyTimeAsDateTime; stores Unix seconds and flags the modify-time field present for encoding.
function GetPermissions: tPermissionFlags;
Getter behind Permissions (POSIX mode bits).
function GetSize: Int64;
Getter behind Size (file length in bytes).
function GetLongName: string;
Getter behind LongName; returns a value only for v3 attributes, always empty on v5.
procedure SetPermissions(const Value: tPermissionFlags);
Setter behind Permissions; also flags the permissions field present for encoding.
procedure SetSize(const Value: Int64);
Setter behind Size; also flags the size field present for encoding.
procedure SetLongName(const Value: string);
Setter behind LongName; effective on v3 only, a no-op on v5.
procedure Decode(const aBuf: tBytes; var aOffset, aCount: Integer);
Parse this attribute record out of the raw SSH packet aBuf starting at aOffset, advancing aOffset/aCount as bytes are consumed. The client calls it when reading an SSH_FXP_ATTRS reply or the file entries of SSH_FXP_NAME.
procedure Encode(const aBuf: tBytes; var aOffset, aCount: Integer);
Serialise this attribute record into the outgoing SSH packet aBuf at aOffset. Called on the client when building setstat/fsetstat, mkdir and open requests.
function GetFullInterfaceGUID: TGUID;
GUID of the version-specific interface (iFileAttributes3 or iFileAttributes5) this object also implements.
function GetFullInterface(out aObj): Boolean;
Casts to that version-specific interface so an app can reach fields absent from this common view; returns False if the cast is unavailable.
property AccessTimeAsDateTime: TDateTime read GetAccessTimeAsDateTime write SetAccessTimeAsDateTime;
File-data access timestamp as a TDateTime; a convenience wrapper over the raw Unix-seconds field. Read from a stat result, or assign it to mark the access time as an attribute to send in a setstat.
property ModifyTimeAsDateTime: TDateTime read GetModifyTimeAsDateTime write SetModifyTimeAsDateTime;
Last-modification timestamp as a TDateTime; assigning it marks the modify time as an attribute to send.
property Size: Int64 read GetSize write SetSize;
File size in bytes; read from a stat result, or set before a setstat to request a truncate/extend of the remote file.
property Permissions: tPermissionFlags read GetPermissions write SetPermissions;
POSIX permission bits (see tPermission); read to inspect a remote file's mode, assign to request a chmod via setstat.
property LongName: string read GetLongName write SetLongName;
Human-readable ls -l style listing line; supplied by v3 servers in a readdir (SSH_FXP_NAME) listing and always empty on v5, whose wire format dropped the longname field.

Types (enumerations, sets, aliases)

enumtPermission

One POSIX mode bit; the enum ordinals line up with the low bits of the wire permissions word (prmExecOther = bit 0 ... prmSUID = the set-uid bit).

  tPermission = (
    prmExecOther,
    prmWriteOther,
    prmReadOther,
    prmExecGroup,
    prmWriteGroup,
    prmReadGroup,
    prmExecUser,
    prmWriteUser,
    prmReadUser,
    prmSVTX,
    prmSGID,
    prmSUID
  );

settPermissionFlags

The full POSIX permission set behind iFileAttributes.Permissions; it is read from and written to the wire as a Word-sized mode word.

  tPermissionFlags = set of tPermission;

Routines