wodSFTP API library - SetAttributes Method
      
 

Description

Sets attributes for a file or folder


Return type

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


Syntax

long Sftp_SetAttributes(void *Sftp, char * RemotePath, __int64 Size, long Uid, long Gid, long Permissions, double AccessTime, double ModificationTime);

The SetAttributes function syntax has these parts:

Part Description
void *Sftp Handle of the created Sftp instance.
char *RemotePath Full path to a file/directory on the server.
__int64 Size New file/directory size.
long Uid Sets user ownership for the file/directory.
long Gid Sets group ownership for the file/directory.
long Permissions Sets file/directory permissions.
double AccessTime Sets last access time.
double ModificationTime Sets last modification time.

Remarks

The SetAttributes function is used to set certain attributes for the file or directory on the server. Although all parameters are optional (set to -1, or NULL for dates), you should set at least one parameter in order to call this method. If RemotePath is not set, then the RemotePath function will be used to determine the file/directory whose attributes are set.

IMPORTANT : if you set the file UID, you must also set GID in the same function call (and vice versa). The same applies when setting AccessTime and ModificationTime. You must set both together because if you omit one of these parameters while setting the other, it will be set to 0 (representing Jan 1, 1970).

If you want to set just one of these parameters, you should first get the attributes of the file/directory and use the retrieved values as the basis for this method.

The value for Permissions is defined by the POSIX standard, which is briefly described below:

- you should represent them in octal (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 indicates execute permission, 2 indicates write permission, 4 indicates read permission. For example, if file Permission AND 777 (octal) gives 754, this is represented on the server as -rwxr-xr-- which means: the owner can read/write/execute, the group can read/execute, and others can only read.

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