Back to product page

GetAttributes function


Retrieves a file or folder attributes.

Type

A Long value. If successful, 0 is returned, otherwise error as specified here

Syntax

  • C
long Sftp_GetAttributes(void *Sftp, char *RemotePath, int FollowSymLink);
The GetAttributes(void *Sftp,char *RemotePath,int FollowSymLink) syntax has these parts:
void *SftpHandle of the created Sftp instance.
char *RemotePathFull path to a file on the server.
int FollowSymLinkSpecifies if symbolic links should be followed.

Remarks

The GetAttributes function will retrieve known information about a file or directory on the remote server. Once these attributes are returned by the server, the Attributes event is fired containing parsed information.

This method will provide you with information about:

Size as long
Uid as long
Gid as long
Permissions as long
AccessTime as Date
ModificationTime as Date

The value for Permissions is defined by the POSIX standard.

This means that you should represent them in the octal base system (base 8) to make parsing them easier Permissions AND 777 (octal) will give you read/write/execute permissions for owner, group and others. Specifically, 1 means execute permission, 2 means write permission, 4 means read permission. For example, if file Permission AND 777 (octal) is 754, this is represented on the server as -rwxr-xr- which means that the owner can read/write/execute, the group can read/execute and others can only read.

To determine if an attribute belongs to a directory, test for Permissions AND 40000 (octal). To determine if an attribute belongs to a symbolic link, test for Permissions AND 120000 (octal).

If you are unfamiliar with representing dates using the double type, you can convert AccessTime and ModificationTime to a SYSTEMTIME structure using the VariantTimeToSystemTime API.

Platforms

Windows