Documentation
¶
Index ¶
- Constants
- type AttrVariant
- type Attribute
- func (attribute Attribute) ToAttributeValue() AttributeValue
- func (attribute Attribute) ToByte() byte
- func (attribute Attribute) ToChar() byte
- func (attribute Attribute) ToRwx() [3]byte
- func (attribute Attribute) ToRwxString() string
- func (attribute Attribute) ToSpecificBytes() (read, write, exe, sum byte)
- func (attribute Attribute) ToSum() byte
- func (attribute Attribute) ToVariant() AttrVariant
- type AttributeValue
- type Variant
- type Wrapper
- func New(mode string) (Wrapper, error)
- func NewUsingAttrVariants(owner, group, other AttrVariant) Wrapper
- func NewUsingAttrs(owner, group, other Attribute) Wrapper
- func NewUsingByte(owner, group, other byte) Wrapper
- func NewUsingBytes(allBytes [3]byte) Wrapper
- func NewUsingFileMode(fileMode os.FileMode) Wrapper
- func NewUsingRwxes(rwxrwxrwx string) (Wrapper, error)
- func NewUsingVariant(variant Variant) (Wrapper, error)
- func (wrapper Wrapper) ApplyChmod(fileOrDirectoryPath string) error
- func (wrapper Wrapper) Bytes() [3]byte
- func (wrapper Wrapper) Chars() [4]byte
- func (wrapper Wrapper) MustApplyChmod(fileOrDirectoryPath string)
- func (wrapper Wrapper) String() string
- func (wrapper Wrapper) ToFileMode() os.FileMode
- func (wrapper Wrapper) ToFileModeString() string
- func (wrapper Wrapper) ToModeStr() string
- func (wrapper Wrapper) ToRwxes() string
- func (wrapper Wrapper) ToRwxesChars() []byte
- func (wrapper Wrapper) ToUint32Octal() uint32
Constants ¶
const ( SupportedLengthString = "3" SupportedLength = 3 ReadValue = 4 WriteValue = 2 ExecuteValue = 1 ReadWriteValue = ReadValue + WriteValue ReadExecuteValue = ReadValue + ExecuteValue WriteExecuteValue = WriteValue + ExecuteValue ReadWriteExecuteValue = ReadValue + WriteValue + ExecuteValue OwnerIndex = 0 GroupIndex = 1 OtherIndex = 2 ReadChar byte = 'r' WriteChar byte = 'w' ExecuteChar byte = 'x' )
Reference : https://ss64.com/bash/chmod.html
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttrVariant ¶
type AttrVariant byte
1 - Execute true 2 - Write true 3 - Write + Execute true 4 - Read true 5 - Read + Execute true 6 - Read + Write true 7 - Read + Write + Execute all true
const ( Execute AttrVariant = 1 Write AttrVariant = 2 WriteExecute AttrVariant = 3 Read AttrVariant = 4 ReadExecute AttrVariant = 5 ReadWrite AttrVariant = 6 ReadWriteExecute AttrVariant = 7 )
func (AttrVariant) IsGreaterThan ¶
func (attrVariant AttrVariant) IsGreaterThan(v byte) bool
v > byte(attrVariant)
func (AttrVariant) String ¶
func (attrVariant AttrVariant) String() string
func (AttrVariant) ToAttribute ¶
func (attrVariant AttrVariant) ToAttribute() Attribute
func (AttrVariant) Value ¶
func (attrVariant AttrVariant) Value() byte
type Attribute ¶
func NewAttribute ¶
func NewAttributeUsingByte ¶
1 - Execute true 2 - Write true 3 - Write + Execute true 4 - Read true 5 - Read + Execute true 6 - Read + Write true 7 - Read + Write + Execute all true
func NewAttributeUsingRwx ¶
Length must be 3 "rwx" should be put for attributes. eg. read enable all disable : "r--" eg. write enable all disable : "-w-" eg. execute enable all disable : "--x" eg. all enabled : "rwx"
func NewAttributeUsingVariant ¶
func NewAttributeUsingVariant(v AttrVariant) Attribute
func (Attribute) ToAttributeValue ¶
func (attribute Attribute) ToAttributeValue() AttributeValue
func (Attribute) ToRwxString ¶
func (Attribute) ToSpecificBytes ¶
func (Attribute) ToVariant ¶
func (attribute Attribute) ToVariant() AttrVariant
type AttributeValue ¶
type AttributeValue struct {
Read, Write, Execute, Sum byte
}
type Variant ¶
type Variant string
const ( AllRead Variant = "444" AllWrite Variant = "222" AllExecute Variant = "111" AllReadWrite Variant = "666" AllReadExecute Variant = "555" AllWriteExecute Variant = "333" OwnerAllReadWriteGroupOther Variant = "755" ReadWriteOwnerReadGroupOther Variant = "644" ReadWriteOwnerReadExecuteGroupOther Variant = "655" All Variant = "777" )
type Wrapper ¶
type Wrapper struct {
Owner, Group, Other Attribute
}
func New ¶
mode length needs to 3, not more not less mode chars should be digits only (0-7) example "777", "755", "655"
func NewUsingAttrVariants ¶
func NewUsingAttrVariants(owner, group, other AttrVariant) Wrapper
func NewUsingAttrs ¶
func NewUsingByte ¶
each byte should not be more than 7
func NewUsingBytes ¶
each byte should not be more than 7
func NewUsingFileMode ¶
func NewUsingRwxes ¶
Format "rwxrwxrwx" eg. owener all enabled only "rwx------" length must be 9 always.
func NewUsingVariant ¶
func (Wrapper) ApplyChmod ¶
func (Wrapper) Chars ¶
return 0rwx, '0'(Owner + '0')(Group + '0')(Other + '0') eg. 0777, 0555, 0755 NOT 0rwx
func (Wrapper) MustApplyChmod ¶
func (Wrapper) ToFileMode ¶
func (Wrapper) ToFileModeString ¶
4 digit string 0rwx, example 0777