Source File
permissions.go
Belonging Package
github.com/pkg/sftp/internal/encoding/ssh/filexfer
package sshfx// FileMode represents a file’s mode and permission bits.// The bits are defined according to POSIX standards,// and may not apply to the OS being built for.type FileMode uint32// Permission flags, defined here to avoid potential inconsistencies in individual OS implementations.const (ModePerm FileMode = 0o0777 // S_IRWXU | S_IRWXG | S_IRWXOModeUserRead FileMode = 0o0400 // S_IRUSRModeUserWrite FileMode = 0o0200 // S_IWUSRModeUserExec FileMode = 0o0100 // S_IXUSRModeGroupRead FileMode = 0o0040 // S_IRGRPModeGroupWrite FileMode = 0o0020 // S_IWGRPModeGroupExec FileMode = 0o0010 // S_IXGRPModeOtherRead FileMode = 0o0004 // S_IROTHModeOtherWrite FileMode = 0o0002 // S_IWOTHModeOtherExec FileMode = 0o0001 // S_IXOTHModeSetUID FileMode = 0o4000 // S_ISUIDModeSetGID FileMode = 0o2000 // S_ISGIDModeSticky FileMode = 0o1000 // S_ISVTXModeType FileMode = 0xF000 // S_IFMTModeNamedPipe FileMode = 0x1000 // S_IFIFOModeCharDevice FileMode = 0x2000 // S_IFCHRModeDir FileMode = 0x4000 // S_IFDIRModeDevice FileMode = 0x6000 // S_IFBLKModeRegular FileMode = 0x8000 // S_IFREGModeSymlink FileMode = 0xA000 // S_IFLNKModeSocket FileMode = 0xC000 // S_IFSOCK)// IsDir reports whether m describes a directory.// That is, it tests for m.Type() == ModeDir.func ( FileMode) () bool {return ( & ModeType) == ModeDir}// IsRegular reports whether m describes a regular file.// That is, it tests for m.Type() == ModeRegularfunc ( FileMode) () bool {return ( & ModeType) == ModeRegular}// Perm returns the POSIX permission bits in m (m & ModePerm).func ( FileMode) () FileMode {return ( & ModePerm)}// Type returns the type bits in m (m & ModeType).func ( FileMode) () FileMode {return ( & ModeType)}// String returns a `-rwxrwxrwx` style string representing the `ls -l` POSIX permissions string.func ( FileMode) () string {var [10]byteswitch .Type() {case ModeRegular:[0] = '-'case ModeDir:[0] = 'd'case ModeSymlink:[0] = 'l'case ModeDevice:[0] = 'b'case ModeCharDevice:[0] = 'c'case ModeNamedPipe:[0] = 'p'case ModeSocket:[0] = 's'default:[0] = '?'}const = "rwxrwxrwx"for , := range {if &(1<<uint(9-1-)) != 0 {[+1] = byte()} else {[+1] = '-'}}if &ModeSetUID != 0 {if [3] == 'x' {[3] = 's'} else {[3] = 'S'}}if &ModeSetGID != 0 {if [6] == 'x' {[6] = 's'} else {[6] = 'S'}}if &ModeSticky != 0 {if [9] == 'x' {[9] = 't'} else {[9] = 'T'}}return string([:])}
![]() |
The pages are generated with Golds v0.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. |