package sftp// Methods on the Request object to make working with the Flags bitmasks and// Attr(ibutes) byte blob easier. Use Pflags() when working with an Open/Write// request and AttrFlags() and Attributes() when working with SetStat requests.import// FileOpenFlags defines Open and Write Flags. Correlate directly with with os.OpenFile flags// (https://golang.org/pkg/os/#pkg-constants).typeFileOpenFlagsstruct { Read, Write, Append, Creat, Trunc, Excl bool}func newFileOpenFlags( uint32) FileOpenFlags {returnFileOpenFlags{Read: &sshFxfRead != 0,Write: &sshFxfWrite != 0,Append: &sshFxfAppend != 0,Creat: &sshFxfCreat != 0,Trunc: &sshFxfTrunc != 0,Excl: &sshFxfExcl != 0, }}// Pflags converts the bitmap/uint32 from SFTP Open packet pflag values,// into a FileOpenFlags struct with booleans set for flags set in bitmap.func ( *Request) () FileOpenFlags {returnnewFileOpenFlags(.Flags)}// FileAttrFlags that indicate whether SFTP file attributes were passed. When a flag is// true the corresponding attribute should be available from the FileStat// object returned by Attributes method. Used with SetStat.typeFileAttrFlagsstruct { Size, UidGid, Permissions, Acmodtime bool}func newFileAttrFlags( uint32) FileAttrFlags {returnFileAttrFlags{Size: ( & sshFileXferAttrSize) != 0,UidGid: ( & sshFileXferAttrUIDGID) != 0,Permissions: ( & sshFileXferAttrPermissions) != 0,Acmodtime: ( & sshFileXferAttrACmodTime) != 0, }}// AttrFlags returns a FileAttrFlags boolean struct based on the// bitmap/uint32 file attribute flags from the SFTP packaet.func ( *Request) () FileAttrFlags {returnnewFileAttrFlags(.Flags)}// FileMode returns the Mode SFTP file attributes wrapped as os.FileModefunc ( FileStat) () os.FileMode {returnos.FileMode(.Mode)}// Attributes parses file attributes byte blob and return them in a// FileStat object.func ( *Request) () *FileStat { , := unmarshalFileStat(.Flags, .Attrs)return}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.