Add SetExtendedData to Client

Add function to set extended attributes in the sftp client.

Signed-off-by: Peter Verraedt <peter@verraedt.be>

Add longer comment

Signed-off-by: Peter Verraedt <peter@verraedt.be>
This commit is contained in:
Peter Verraedt 2023-07-13 17:15:31 +02:00
parent 6370888833
commit 0814039fdf
No known key found for this signature in database
GPG Key ID: 43DBD0DF85B59F0C
1 changed files with 14 additions and 0 deletions

View File

@ -593,6 +593,20 @@ func (c *Client) Truncate(path string, size int64) error {
return c.setstat(path, sshFileXferAttrSize, uint64(size))
}
// SetExtendedData sets extended attributes of the named file. It uses the
// SSH_FILEXFER_ATTR_EXTENDED flag in the setstat request.
//
// This flag provides a general extension mechanism for vendor-specific extensions.
// Names of the attributes should be a string of the format "name@domain", where "domain"
// is a valid, registered domain name and "name" identifies the method. Server
// implementations SHOULD ignore extended data fields that they do not understand.
func (c *Client) SetExtendedData(path string, extended []StatExtended) error {
attrs := &FileStat{
Extended: extended,
}
return c.setstat(path, sshFileXferAttrExtended, attrs)
}
// Open opens the named file for reading. If successful, methods on the
// returned file can be used for reading; the associated file descriptor
// has mode O_RDONLY.