GetAttributes Event

Fires when a client needs to get file information.

Syntax

ANSI (Cross Platform)
virtual int FireGetAttributes(SFTPServerGetAttributesEventParams *e);
typedef struct {
int ConnectionId;
const char *User;
const char *Path;
int Flags;
int FileType;
int64 *pFileSize;
char *FileOwner;
char *FileGroup;
int FilePermissions;
int64 *pFileATime;
int64 *pFileCreateTime;
int64 *pFileMTime;
int FileAttribBits;
int FileAttribBitsValid;
char *OtherAttributes;
int StatusCode; int reserved; } SFTPServerGetAttributesEventParams; Unicode (Windows) virtual INT FireGetAttributes(SFTPServerGetAttributesEventParams *e);
typedef struct {
INT ConnectionId;
LPCWSTR User;
LPCWSTR Path;
INT Flags;
INT FileType;
LONG64 *pFileSize;
LPWSTR FileOwner;
LPWSTR FileGroup;
INT FilePermissions;
LONG64 *pFileATime;
LONG64 *pFileCreateTime;
LONG64 *pFileMTime;
INT FileAttribBits;
INT FileAttribBitsValid;
LPWSTR OtherAttributes;
INT StatusCode; INT reserved; } SFTPServerGetAttributesEventParams;
- (void)onGetAttributes:(int)connectionId :(NSString*)user :(NSString*)path :(int)flags :(int*)fileType :(long long*)fileSize :(NSString**)fileOwner :(NSString**)fileGroup :(int*)filePermissions :(long long*)fileATime :(long long*)fileCreateTime :(long long*)fileMTime :(int*)fileAttribBits :(int*)fileAttribBitsValid :(NSString**)otherAttributes :(int*)statusCode;
#define EID_SFTPSERVER_GETATTRIBUTES 14

virtual INT IPWORKSSFTP_CALL FireGetAttributes(INT &iConnectionId, LPSTR &lpszUser, LPSTR &lpszPath, INT &iFlags, INT &iFileType, LONG64 &lFileSize, LPSTR &lpszFileOwner, LPSTR &lpszFileGroup, INT &iFilePermissions, LONG64 &lFileATime, LONG64 &lFileCreateTime, LONG64 &lFileMTime, INT &iFileAttribBits, INT &iFileAttribBitsValid, LPSTR &lpszOtherAttributes, INT &iStatusCode);

Remarks

The GetAttributes event fires when an SFTP client sends an SSH_FXP_STAT, SSH_FXP_LSTAT or SSH_FXP_FSTAT request. Path is the file path. Flags specifies the set of file attributes the client is interested in.

File/Directory Attributes are specified using the following values:

FileType: The type of file. Can be one of the following values:

  • SSH_FILEXFER_TYPE_REGULAR (1)
  • SSH_FILEXFER_TYPE_DIRECTORY (2)
  • SSH_FILEXFER_TYPE_SYMLINK (3)
  • SSH_FILEXFER_TYPE_SPECIAL (4)
  • SSH_FILEXFER_TYPE_UNKNOWN (5)
  • SSH_FILEXFER_TYPE_SOCKET (6)
  • SSH_FILEXFER_TYPE_CHAR_DEVICE (7)
  • SSH_FILEXFER_TYPE_BLOCK_DEVICE (8)
  • SSH_FILEXFER_TYPE_FIFO (9)

FileSize: The file size, in bytes.

FileOwner: The file owner. If the ProtocolVersion configuration option is "3" (default), this field should be a numeric Unix-like user identifier. V4-V6 of the SFTP Protocol allow an arbitrary string.

FileGroup: The file owner group. If the ProtocolVersion configuration option is "3" (default), this field should be a numeric Unix-like group identifier. V4-V6 of the SFTP Protocol allow an arbitrary string.

FilePermissions: The POSIX-style file permissions.

FileATime: The file last-access time, in milliseconds since Jan 1, 1970 in UTC.

FileCreateTime: The file creation time, in milliseconds since Jan 1, 1970 in UTC.

FileMTime: The file last-modified time, in milliseconds since Jan 1, 1970 in UTC.

FileAttrBits: The file attributes, as a combination of the following values:

  • SSH_FILEXFER_ATTR_FLAGS_READONLY (0x00000001)
  • SSH_FILEXFER_ATTR_FLAGS_SYSTEM (0x00000002)
  • SSH_FILEXFER_ATTR_FLAGS_HIDDEN (0x00000004)
  • SSH_FILEXFER_ATTR_FLAGS_CASE_INSENSITIVE (0x00000008)
  • SSH_FILEXFER_ATTR_FLAGS_ARCHIVE (0x00000010)
  • SSH_FILEXFER_ATTR_FLAGS_ENCRYPTED (0x00000020)
  • SSH_FILEXFER_ATTR_FLAGS_COMPRESSED (0x00000040)
  • SSH_FILEXFER_ATTR_FLAGS_SPARSE (0x00000080)
  • SSH_FILEXFER_ATTR_FLAGS_APPEND_ONLY (0x00000100)
  • SSH_FILEXFER_ATTR_FLAGS_IMMUTABLE (0x00000200)
  • SSH_FILEXFER_ATTR_FLAGS_SYNC (0x00000400)
  • SSH_FILEXFER_ATTR_FLAGS_TRANSLATION_ERR (0x00000800)

FileAttrBitsValid: A mask specifying which bits in FileAttrBits are supported by the server.

OtherAttributes: A semi-colon (';') delimited list of Name=Value pairs of other attributes supported by SFTP. These include:

  • MIMEType (String)
  • AllocationSize (64-bit int)
  • ATimeNS (int): ATime nanoseconds
  • CreateTimeNS (int): CreateTime nanoseconds
  • MTimeNS (int): MTime nanoseconds
  • TextHint (8-bit int)
  • LinkCount (int)
  • UntranslatedName (String)

FileMimeType: The MIME type of the file.

Valid status codes are:

  • SSH_FX_OK 0
  • SSH_FX_EOF 1
  • SSH_FX_NO_SUCH_FILE 2
  • SSH_FX_PERMISSION_DENIED 3
  • SSH_FX_FAILURE 4
  • SSH_FX_BAD_MESSAGE 5
  • SSH_FX_NO_CONNECTION 6
  • SSH_FX_CONNECTION_LOST 7
  • SSH_FX_OP_UNSUPPORTED 8
  • SSH_FX_INVALID_HANDLE 9
  • SSH_FX_NO_SUCH_PATH 10
  • SSH_FX_FILE_ALREADY_EXISTS 11
  • SSH_FX_WRITE_PROTECT 12
  • SSH_FX_NO_MEDIA 13
  • SSH_FX_NO_SPACE_ON_FILESYSTEM 14
  • SSH_FX_QUOTA_EXCEEDED 15
  • SSH_FX_UNKNOWN_PRINCIPAL 16
  • SSH_FX_LOCK_CONFLICT 17
  • SSH_FX_DIR_NOT_EMPTY 18
  • SSH_FX_NOT_A_DIRECTORY 19
  • SSH_FX_INVALID_FILENAME 20
  • SSH_FX_LINK_LOOP 21
  • SSH_FX_CANNOT_DELETE 22
  • SSH_FX_INVALID_PARAMETER 23
  • SSH_FX_FILE_IS_A_DIRECTORY 24
  • SSH_FX_BYTE_RANGE_LOCK_CONFLICT 25
  • SSH_FX_BYTE_RANGE_LOCK_REFUSED 26
  • SSH_FX_DELETE_PENDING 27
  • SSH_FX_FILE_CORRUPT 28
  • SSH_FX_OWNER_INVALID 29
  • SSH_FX_GROUP_INVALID 30
  • SSH_FX_NO_MATCHING_BYTE_RANGE_LOCK 31

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks SFTP 2020 C++ Edition - Version 20.0 [Build 8162]