Skip to content

Commit

Permalink
Add fsetstat variant of SetExtendedData
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Verraedt <peter@verraedt.be>
  • Loading branch information
peterverraedt committed Apr 25, 2024
1 parent 0814039 commit 478aa2e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions client.go
Expand Up @@ -2058,6 +2058,28 @@ func (f *File) Chmod(mode os.FileMode) error {
return f.c.fsetstat(f.handle, sshFileXferAttrPermissions, toChmodPerm(mode))
}

// SetExtendedData sets extended attributes of the current 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 (f *File) SetExtendedData(path string, extended []StatExtended) error {
f.mu.RLock()
defer f.mu.RUnlock()

if f.handle == "" {
return os.ErrClosed
}

attrs := &FileStat{
Extended: extended,
}

return f.c.fsetstat(f.handle, sshFileXferAttrExtended, attrs)
}

// Truncate sets the size of the current file. Although it may be safely assumed
// that if the size is less than its current size it will be truncated to fit,
// the SFTP protocol does not specify what behavior the server should do when setting
Expand Down

0 comments on commit 478aa2e

Please sign in to comment.