@@ -593,6 +593,20 @@ func (c *Client) Truncate(path string, size int64) error {
593
593
return c .setstat (path , sshFileXferAttrSize , uint64 (size ))
594
594
}
595
595
596
+ // SetExtendedData sets extended attributes of the named file. It uses the
597
+ // SSH_FILEXFER_ATTR_EXTENDED flag in the setstat request.
598
+ //
599
+ // This flag provides a general extension mechanism for vendor-specific extensions.
600
+ // Names of the attributes should be a string of the format "name@domain", where "domain"
601
+ // is a valid, registered domain name and "name" identifies the method. Server
602
+ // implementations SHOULD ignore extended data fields that they do not understand.
603
+ func (c * Client ) SetExtendedData (path string , extended []StatExtended ) error {
604
+ attrs := & FileStat {
605
+ Extended : extended ,
606
+ }
607
+ return c .setstat (path , sshFileXferAttrExtended , attrs )
608
+ }
609
+
596
610
// Open opens the named file for reading. If successful, methods on the
597
611
// returned file can be used for reading; the associated file descriptor
598
612
// has mode O_RDONLY.
@@ -2044,6 +2058,28 @@ func (f *File) Chmod(mode os.FileMode) error {
2044
2058
return f .c .fsetstat (f .handle , sshFileXferAttrPermissions , toChmodPerm (mode ))
2045
2059
}
2046
2060
2061
+ // SetExtendedData sets extended attributes of the current file. It uses the
2062
+ // SSH_FILEXFER_ATTR_EXTENDED flag in the setstat request.
2063
+ //
2064
+ // This flag provides a general extension mechanism for vendor-specific extensions.
2065
+ // Names of the attributes should be a string of the format "name@domain", where "domain"
2066
+ // is a valid, registered domain name and "name" identifies the method. Server
2067
+ // implementations SHOULD ignore extended data fields that they do not understand.
2068
+ func (f * File ) SetExtendedData (path string , extended []StatExtended ) error {
2069
+ f .mu .RLock ()
2070
+ defer f .mu .RUnlock ()
2071
+
2072
+ if f .handle == "" {
2073
+ return os .ErrClosed
2074
+ }
2075
+
2076
+ attrs := & FileStat {
2077
+ Extended : extended ,
2078
+ }
2079
+
2080
+ return f .c .fsetstat (f .handle , sshFileXferAttrExtended , attrs )
2081
+ }
2082
+
2047
2083
// Truncate sets the size of the current file. Although it may be safely assumed
2048
2084
// that if the size is less than its current size it will be truncated to fit,
2049
2085
// the SFTP protocol does not specify what behavior the server should do when setting
0 commit comments