chmodhelper

package
v1.3.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 23 Imported by: 17

Documentation

Index

Constants

View Source
const (
	SingleRwxLengthString            = "3"
	HyphenedRwxLength                = constants.ArbitraryCapacity10
	HyphenedRwxLengthString          = constants.N10String
	FullRwxLengthWithoutHyphenString = constants.N9String
	FullRwxLengthWithoutHyphen       = constants.ArbitraryCapacity9
	SingleRwxLength                  = 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'
	NopChar      byte = '-'
	WriteChar    byte = 'w'
	ExecuteChar  byte = 'x'
	AllWildcards      = "***"
)

Reference : https://ss64.com/bash/chmod.html

Variables

This section is empty.

Functions

func CreateDirFilesWithRwxPermission added in v0.6.9

func CreateDirFilesWithRwxPermission(
	isRemoveAllDirBeforeCreate bool,
	dirFilesWithRwxPermission *DirFilesWithRwxPermission,
) error

func CreateDirFilesWithRwxPermissions added in v0.6.9

func CreateDirFilesWithRwxPermissions(
	isRemoveAllDirBeforeCreate bool,
	dirFilesWithRwxPermissions *[]*DirFilesWithRwxPermission,
) error

func CreateDirFilesWithRwxPermissionsMust added in v0.6.9

func CreateDirFilesWithRwxPermissionsMust(
	isRemoveAllDirBeforeCreate bool,
	dirFilesWithRwxPermissions *[]*DirFilesWithRwxPermission,
)

func CreateDirWithFiles added in v0.6.9

func CreateDirWithFiles(
	isRemoveAllDirBeforeCreate bool,
	fileChmod os.FileMode,
	dirWithFile *DirWithFiles,
) error

func CreateDirsWithFiles added in v0.6.9

func CreateDirsWithFiles(
	isRemoveAllDirBeforeCreate bool,
	fileChmod os.FileMode,
	dirsWithFiles *[]DirWithFiles,
) error

func ExpandCharRwx added in v0.5.4

func ExpandCharRwx(rwx string) (r, w, x byte)

ExpandCharRwx Expands to 'r', 'w', 'x'

func FileModeApplyChmod added in v0.5.5

func FileModeApplyChmod(
	fileMode os.FileMode,
	condition *chmodins.Condition,
	locations ...string,
) error

func GetExistingChmod

func GetExistingChmod(filePath string) (os.FileMode, error)

func GetExistingChmodRwxWrappers added in v0.6.2

func GetExistingChmodRwxWrappers(
	isContinueOnError bool,
	filePaths ...string,
) (filePathToRwxWrapper *map[string]*RwxWrapper, err error)

func GetFilesChmodRwxFullMap added in v0.5.5

func GetFilesChmodRwxFullMap(
	requestedPaths []string,
) (filePathToRwxMap *corestr.Hashmap, err error)

GetFilesChmodRwxFullMap returns filePath -> "-rwxrwxrwx"

func GetFilesChmodRwxFullMapDirect added in v0.5.5

func GetFilesChmodRwxFullMapDirect(
	requestedPaths ...string,
) (*corestr.Hashmap, error)

GetFilesChmodRwxFullMapDirect returns filePath -> "-rwxrwxrwx"

func GetFilteredExistsFilesInfosOnly added in v0.6.2

func GetFilteredExistsFilesInfosOnly(
	locations []string,
) map[string]os.FileInfo

GetFilteredExistsFilesInfosOnly

Warning: File related errors will be swallowed

func GetFilteredExistsPaths added in v0.6.2

func GetFilteredExistsPaths(locations []string) (
	foundFiles, missingOrPathsWithIssues []string,
)

func GetPathExistStatExpand added in v0.6.9

func GetPathExistStatExpand(location string) (fileInfo os.FileInfo, isExist bool, err error)

func GetRecursivePaths added in v0.8.0

func GetRecursivePaths(
	isContinueOnError bool,
	rootPath string,
) ([]string, error)

func GetRecursivePathsContinueOnError added in v0.8.1

func GetRecursivePathsContinueOnError(
	rootPath string,
) ([]string, error)

func GetRwxLengthError added in v0.4.1

func GetRwxLengthError(rwx string) error

func IsChmod added in v0.4.1

func IsChmod(location string, expectedHyphenedRwx string) bool

IsChmod expectedHyphenedRwx should be 10 chars example "-rwxrwxrwx"

func IsChmodEqualUsingRwxOwnerGroupOther added in v0.4.1

func IsChmodEqualUsingRwxOwnerGroupOther(
	location string,
	rwx *chmodins.RwxOwnerGroupOther,
) bool

func IsDirectory added in v0.6.2

func IsDirectory(location string) bool

func IsPartialMatchVariableAttr added in v0.6.2

func IsPartialMatchVariableAttr(
	givenVarAttr *VarAttribute,
	rwx string,
) bool

func IsPathExists added in v0.6.2

func IsPathExists(location string) bool

func IsPathExistsPlusFileInfo added in v0.6.2

func IsPathExistsPlusFileInfo(location string) (bool, os.FileInfo)

func NewRwxInstruction added in v0.5.5

func NewRwxInstruction(
	rwxFullString string,
	condition chmodins.Condition,
) (*chmodins.RwxInstruction, error)

NewRwxInstruction rwxFullString must be 10 chars in "-rwxrwxrwx"

func ParseRwxInstructionToStringRwx added in v0.4.1

func ParseRwxInstructionToStringRwx(
	rwxInstruction *chmodins.RwxOwnerGroupOther,
	isIncludeHyphen bool,
) string

func ParseRwxOwnerGroupOtherToFileMode added in v0.6.9

func ParseRwxOwnerGroupOtherToFileMode(
	rwxOwnerGroupOther *chmodins.RwxOwnerGroupOther,
) (os.FileMode, error)

func ParseRwxOwnerGroupOtherToFileModeMust added in v0.6.9

func ParseRwxOwnerGroupOtherToFileModeMust(
	rwxOwnerGroupOther *chmodins.RwxOwnerGroupOther,
) os.FileMode

func RecursivePathsApply added in v0.8.0

func RecursivePathsApply(
	rootPath string,
	actionFunc func(currentPath string, info fs.FileInfo, err error) error,
) error

func RwxOwnerGroupOtherApplyChmod added in v0.5.6

func RwxOwnerGroupOtherApplyChmod(
	rwxOwnerGroupOther *chmodins.RwxOwnerGroupOther,
	condition *chmodins.Condition,
	locations ...string,
) error

RwxOwnerGroupOtherApplyChmod rwxFullString 10 chars "-rwxrwxrwx"

func RwxPartialApplyChmod added in v0.6.2

func RwxPartialApplyChmod(
	rwxPartial string,
	condition *chmodins.Condition,
	locations ...string,
) error

RwxPartialApplyChmod rwxPartial can be any length in between 0-10 (rest will be fixed by wildcard)

rwxPartial:

  • "-rwx" will be "-rwx******"
  • "-rwxr-x" will be "-rwxr-x***"
  • "-rwxr-x" will be "-rwxr-x***"

func RwxStringApplyChmod added in v0.5.5

func RwxStringApplyChmod(
	rwxFullString string,
	condition *chmodins.Condition,
	locations ...string,
) error

RwxStringApplyChmod rwxFullString 10 chars "-rwxrwxrwx"

func VerifyChmod added in v0.4.1

func VerifyChmod(location string, expectedHyphenedRwx string) error

VerifyChmod - expectedHyphenedRwx should be 10 chars example "-rwxrwxrwx"

func VerifyChmodLocationsUsingPartialRwx added in v0.6.2

func VerifyChmodLocationsUsingPartialRwx(
	isContinueOnError,
	isSkipOnInvalid bool,
	partialRwx string,
	locations []string,
) error

func VerifyChmodLocationsUsingPartialRwxDirect added in v0.6.2

func VerifyChmodLocationsUsingPartialRwxDirect(
	isContinueOnError,
	isSkipOnInvalid bool,
	partialRwx string,
	locations ...string,
) error

func VerifyChmodPaths added in v0.4.1

func VerifyChmodPaths(
	locations *[]string,
	expectedHyphenedRwx string,
	isContinueOnError bool,
) error

func VerifyChmodPathsDirect added in v0.5.6

func VerifyChmodPathsDirect(
	expectedHyphenedRwx string,
	isContinueOnError bool,
	locations ...string,
) error

VerifyChmodPathsDirect - expectedHyphenedRwx should be 10 chars example "-rwxrwxrwx"

Multiple files verification error will be returned as once.

func VerifyChmodUsingHashmap added in v0.5.6

func VerifyChmodUsingHashmap(
	filePathToRwxMap *corestr.Hashmap,
) error

VerifyChmodUsingHashmap - expectedHyphenedRwx should be 10 chars example "-rwxrwxrwx"

Multiple files verification error will be returned as once. nil will be returned if no error

func VerifyChmodUsingRwxOwnerGroupOther added in v0.4.1

func VerifyChmodUsingRwxOwnerGroupOther(
	location string,
	rwx *chmodins.RwxOwnerGroupOther,
) error

Types

type AttrVariant

type AttrVariant byte

AttrVariant

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

IsGreaterThan 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

type Attribute struct {
	IsRead    bool
	IsWrite   bool
	IsExecute bool
}

func MergeRwxWildcardWithFixedRwx added in v0.4.1

func MergeRwxWildcardWithFixedRwx(
	existingRwx,
	rwxWildcardInput string,
) (
	fixedAttribute *Attribute,
	err error,
)

MergeRwxWildcardWithFixedRwx

  • existingRwx : Usually refers to fixed rwx values like "rwx", "--x", "-w-" etc.
  • rwxWildcardInput : Usually refers to fixed rwx values like "rw*", "*-x", "-w-" etc. Wildcard means keep the existing value as is.

func NewAttribute

func NewAttribute(isRead, isWrite, isExecute bool) Attribute

func NewAttributeUsingByte

func NewAttributeUsingByte(v byte) Attribute

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

func NewAttributeUsingRwx(rwx string) Attribute

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) Clone added in v0.5.4

func (attribute *Attribute) Clone() *Attribute

func (Attribute) IsEqual added in v0.6.2

func (attribute Attribute) IsEqual(next Attribute) bool

func (*Attribute) IsEqualPtr added in v0.6.2

func (attribute *Attribute) IsEqualPtr(next *Attribute) bool

func (*Attribute) ToAttributeValue

func (attribute *Attribute) ToAttributeValue() AttributeValue

func (*Attribute) ToByte

func (attribute *Attribute) ToByte() byte

ToByte refers to the compiled byte value in between 0-7

func (*Attribute) ToRwx

func (attribute *Attribute) ToRwx() [3]byte

func (*Attribute) ToRwxString

func (attribute *Attribute) ToRwxString() string

ToRwxString returns "rwx"

func (*Attribute) ToSpecificBytes

func (attribute *Attribute) ToSpecificBytes() (read, write, exe, sum byte)

func (*Attribute) ToStringByte added in v0.4.4

func (attribute *Attribute) ToStringByte() byte

ToStringByte returns the compiled byte value as Char byte value

It is not restricted between 0-7 but 0-7 + char '0', which makes it string 0-7

func (*Attribute) ToSum

func (attribute *Attribute) ToSum() byte

ToSum refers to the compiled byte value in between 0-7

func (*Attribute) ToVariant

func (attribute *Attribute) ToVariant() AttrVariant

type AttributeValue

type AttributeValue struct {
	Read, Write, Execute, Sum byte
}

type DirFilesWithRwxPermission added in v0.6.9

type DirFilesWithRwxPermission struct {
	DirWithFiles
	ApplyRwx chmodins.RwxOwnerGroupOther
}

func (*DirFilesWithRwxPermission) CreatePaths added in v0.6.9

func (it *DirFilesWithRwxPermission) CreatePaths(
	isRemoveBeforeCreate bool,
) error

func (*DirFilesWithRwxPermission) CreatePathsUsingFileMode added in v0.6.9

func (it *DirFilesWithRwxPermission) CreatePathsUsingFileMode(
	isRemoveBeforeCreate bool,
	fileMode os.FileMode,
) error

func (*DirFilesWithRwxPermission) GetFilesChmodMap added in v0.6.9

func (it *DirFilesWithRwxPermission) GetFilesChmodMap() *corestr.Hashmap

func (*DirFilesWithRwxPermission) GetPaths added in v0.6.9

func (it *DirFilesWithRwxPermission) GetPaths() []string

func (*DirFilesWithRwxPermission) GetPathsPtr added in v0.6.9

func (it *DirFilesWithRwxPermission) GetPathsPtr() *[]string

type DirWithFiles added in v0.6.9

type DirWithFiles struct {
	Dir   string
	Files []string
}

func (*DirWithFiles) CreatePaths added in v0.6.9

func (it *DirWithFiles) CreatePaths(
	isRemoveBeforeCreate bool,
	fileMode os.FileMode,
) error

type FilteredPathFileInfoMap added in v0.6.2

type FilteredPathFileInfoMap struct {
	FilesToInfoMap           map[string]os.FileInfo
	PathsRemainsUnProcessed  []string // TODO
	MissingOrOtherPathIssues []string
	Error                    error
	// contains filtered or unexported fields
}

func GetExistsFilteredPathFileInfoMap added in v0.6.2

func GetExistsFilteredPathFileInfoMap(
	isSkipOnInvalid bool,
	locations []string,
) *FilteredPathFileInfoMap

func InvalidFilteredPathFileInfoMap added in v0.6.2

func InvalidFilteredPathFileInfoMap() *FilteredPathFileInfoMap

func (*FilteredPathFileInfoMap) HasAnyIssues added in v0.6.2

func (it *FilteredPathFileInfoMap) HasAnyIssues() bool

func (*FilteredPathFileInfoMap) HasAnyMissingPaths added in v0.6.2

func (it *FilteredPathFileInfoMap) HasAnyMissingPaths() bool

func (*FilteredPathFileInfoMap) HasAnyValidFileInfo added in v0.6.2

func (it *FilteredPathFileInfoMap) HasAnyValidFileInfo() bool

func (*FilteredPathFileInfoMap) HasError added in v0.6.3

func (it *FilteredPathFileInfoMap) HasError() bool

func (*FilteredPathFileInfoMap) IsEmptyIssues added in v0.6.2

func (it *FilteredPathFileInfoMap) IsEmptyIssues() bool

func (*FilteredPathFileInfoMap) IsEmptyValidFileInfos added in v0.6.2

func (it *FilteredPathFileInfoMap) IsEmptyValidFileInfos() bool

func (*FilteredPathFileInfoMap) LazyValidLocationFileInfoRwxWrappers added in v0.6.3

func (it *FilteredPathFileInfoMap) LazyValidLocationFileInfoRwxWrappers() []LocationFileInfoRwxWrapper

func (*FilteredPathFileInfoMap) LazyValidLocations added in v0.6.3

func (it *FilteredPathFileInfoMap) LazyValidLocations() []string

func (*FilteredPathFileInfoMap) LengthOfIssues added in v0.6.2

func (it *FilteredPathFileInfoMap) LengthOfIssues() int

func (*FilteredPathFileInfoMap) MissingPathsToString added in v0.6.2

func (it *FilteredPathFileInfoMap) MissingPathsToString() string

func (*FilteredPathFileInfoMap) ValidFileInfos added in v0.6.3

func (it *FilteredPathFileInfoMap) ValidFileInfos() []os.FileInfo

func (*FilteredPathFileInfoMap) ValidLocationFileInfoRwxWrappers added in v0.6.3

func (it *FilteredPathFileInfoMap) ValidLocationFileInfoRwxWrappers() []LocationFileInfoRwxWrapper

func (*FilteredPathFileInfoMap) ValidLocations added in v0.6.3

func (it *FilteredPathFileInfoMap) ValidLocations() []string

type LocationFileInfoRwxWrapper added in v0.6.3

type LocationFileInfoRwxWrapper struct {
	Location   string
	FileInfo   os.FileInfo
	RwxWrapper *RwxWrapper
}

type PathExistStat added in v0.6.9

type PathExistStat struct {
	Location string
	FileInfo os.FileInfo
	IsExist  bool
	Error    error
}

func GetPathExistStat added in v0.6.2

func GetPathExistStat(location string) *PathExistStat

func GetPathExistStats added in v0.9.6

func GetPathExistStats(
	isCollectValidOnly bool,
	locations ...string,
) []*PathExistStat

func (*PathExistStat) CombineWith added in v0.9.5

func (it *PathExistStat) CombineWith(additionalPaths ...string) *PathExistStat

func (*PathExistStat) CombineWithNewPath added in v0.9.5

func (it *PathExistStat) CombineWithNewPath(additionalPaths ...string) string

func (*PathExistStat) Dispose added in v0.9.5

func (it *PathExistStat) Dispose()

func (*PathExistStat) DotExt added in v0.9.5

func (it *PathExistStat) DotExt() (dotExt string)

func (*PathExistStat) FileMode added in v0.9.5

func (it *PathExistStat) FileMode() *os.FileMode

func (*PathExistStat) FileName added in v0.9.5

func (it *PathExistStat) FileName() (filename string)

func (*PathExistStat) HasAnyIssues added in v0.9.5

func (it *PathExistStat) HasAnyIssues() bool

func (*PathExistStat) HasError added in v0.6.9

func (it *PathExistStat) HasError() bool

func (*PathExistStat) HasFileInfo added in v0.6.9

func (it *PathExistStat) HasFileInfo() bool

func (*PathExistStat) IsDir added in v0.6.9

func (it *PathExistStat) IsDir() bool

func (*PathExistStat) IsEmptyError added in v0.6.9

func (it *PathExistStat) IsEmptyError() bool

func (*PathExistStat) IsFile added in v0.6.9

func (it *PathExistStat) IsFile() bool

func (*PathExistStat) IsInvalid added in v0.9.5

func (it *PathExistStat) IsInvalid() bool

func (*PathExistStat) IsInvalidFileInfo added in v0.9.6

func (it *PathExistStat) IsInvalidFileInfo() bool

func (*PathExistStat) LastModifiedDate added in v0.9.5

func (it *PathExistStat) LastModifiedDate() *time.Time

func (*PathExistStat) MeaningFullError added in v0.6.9

func (it *PathExistStat) MeaningFullError() error

func (*PathExistStat) MessageWithPathWrapped added in v0.9.6

func (it *PathExistStat) MessageWithPathWrapped(
	message string,
) string

func (*PathExistStat) NotADirError added in v0.9.6

func (it *PathExistStat) NotADirError() error

NotADirError

Get error on:

  • Path has issues or not exist
  • Expecting dir, if not dir then error

func (*PathExistStat) NotAFileError added in v0.9.6

func (it *PathExistStat) NotAFileError() error

NotAFileError

Get error on:

  • Path has issues or not exist
  • Expecting file, if not file then error

func (*PathExistStat) NotExistError added in v0.9.6

func (it *PathExistStat) NotExistError() error

func (*PathExistStat) Parent added in v0.9.5

func (it *PathExistStat) Parent() *PathExistStat

func (*PathExistStat) ParentDir added in v0.9.5

func (it *PathExistStat) ParentDir() (parentDir string)

func (*PathExistStat) ParentWith added in v0.9.5

func (it *PathExistStat) ParentWith(additionalPaths ...string) *PathExistStat

func (*PathExistStat) ParentWithGlobPatternFiles added in v0.9.5

func (it *PathExistStat) ParentWithGlobPatternFiles(globPatterns ...string) ([]string, error)

func (*PathExistStat) ParentWithNewPath added in v0.9.5

func (it *PathExistStat) ParentWithNewPath(additionalPaths ...string) string

func (*PathExistStat) Size added in v0.9.5

func (it *PathExistStat) Size() *int64

func (*PathExistStat) Split added in v0.9.5

func (it *PathExistStat) Split() (dir, filename string)

func (*PathExistStat) String added in v0.9.6

func (it *PathExistStat) String() string

type RwxInstructionExecutor added in v0.4.1

type RwxInstructionExecutor struct {
	// contains filtered or unexported fields
}

func ParseRwxInstructionToExecutor added in v0.4.1

func ParseRwxInstructionToExecutor(
	rwxInstruction *chmodins.RwxInstruction,
) (
	*RwxInstructionExecutor, error,
)

func RwxPartialToInstructionExecutor added in v0.6.2

func RwxPartialToInstructionExecutor(
	rwxPartial string,
	condition *chmodins.Condition,
) (*RwxInstructionExecutor, error)

RwxPartialToInstructionExecutor rwxPartial can be any length in between 0-10 (rest will be fixed by wildcard)

rwxPartial:

  • "-rwx" will be "-rwx******"
  • "-rwxr-x" will be "-rwxr-x***"
  • "-rwxr-x" will be "-rwxr-x***"

func (*RwxInstructionExecutor) ApplyOnPath added in v0.4.1

func (it *RwxInstructionExecutor) ApplyOnPath(location string) error

func (*RwxInstructionExecutor) ApplyOnPaths added in v0.4.1

func (it *RwxInstructionExecutor) ApplyOnPaths(locations []string) error

func (*RwxInstructionExecutor) ApplyOnPathsDirect added in v0.5.5

func (it *RwxInstructionExecutor) ApplyOnPathsDirect(locations ...string) error

func (*RwxInstructionExecutor) ApplyOnPathsPtr added in v0.5.4

func (it *RwxInstructionExecutor) ApplyOnPathsPtr(locations *[]string) error

func (*RwxInstructionExecutor) CompiledRwxWrapperUsingFixedRwxWrapper added in v0.5.0

func (it *RwxInstructionExecutor) CompiledRwxWrapperUsingFixedRwxWrapper(
	wrapper *RwxWrapper,
) (*RwxWrapper, error)

func (*RwxInstructionExecutor) CompiledWrapper added in v0.4.1

func (it *RwxInstructionExecutor) CompiledWrapper(mode os.FileMode) (*RwxWrapper, error)

func (*RwxInstructionExecutor) IsEqualFileInfo added in v0.6.2

func (it *RwxInstructionExecutor) IsEqualFileInfo(fileInfo os.FileInfo) bool

IsEqualFileInfo fileInfo nil returns false.

func (*RwxInstructionExecutor) IsEqualFileMode added in v0.6.2

func (it *RwxInstructionExecutor) IsEqualFileMode(mode os.FileMode) bool

func (*RwxInstructionExecutor) IsEqualRwxPartial added in v0.6.2

func (it *RwxInstructionExecutor) IsEqualRwxPartial(rwxPartial string) bool

IsEqualRwxPartial

rwxPartial:

  • "-rwx" will be "-rwx******"
  • "-rwxr-x" will be "-rwxr-x***"
  • "-rwxr-x" will be "-rwxr-x***"

func (*RwxInstructionExecutor) IsEqualRwxWrapper added in v0.6.2

func (it *RwxInstructionExecutor) IsEqualRwxWrapper(rwxWrapper *RwxWrapper) bool

IsEqualRwxWrapper nil returns false.

func (*RwxInstructionExecutor) IsFixedWrapper added in v0.4.1

func (it *RwxInstructionExecutor) IsFixedWrapper() bool

IsFixedWrapper true indicates no wildcard symbol

func (*RwxInstructionExecutor) IsVarWrapper added in v0.4.1

func (it *RwxInstructionExecutor) IsVarWrapper() bool

IsVarWrapper if it has any wildcard symbol in it

func (*RwxInstructionExecutor) VerifyRwxModifiers added in v0.6.2

func (it *RwxInstructionExecutor) VerifyRwxModifiers(
	isRecursiveIgnore bool,
	locations []string,
) error

func (*RwxInstructionExecutor) VerifyRwxModifiersDirect added in v0.6.2

func (it *RwxInstructionExecutor) VerifyRwxModifiersDirect(
	isRecursiveIgnore bool,
	locations ...string,
) error

type RwxInstructionExecutors added in v0.4.1

type RwxInstructionExecutors struct {
	// contains filtered or unexported fields
}

func NewRwxInstructionExecutors added in v0.4.1

func NewRwxInstructionExecutors(capacity int) *RwxInstructionExecutors

func ParseBaseRwxInstructionsToExecutors added in v0.4.1

func ParseBaseRwxInstructionsToExecutors(
	baseRwxInstructions *chmodins.BaseRwxInstructions,
) (
	*RwxInstructionExecutors, error,
)

func ParseRwxInstructionsToExecutors added in v0.4.1

func ParseRwxInstructionsToExecutors(
	rwxInstructions []chmodins.RwxInstruction,
) (
	*RwxInstructionExecutors, error,
)

func (*RwxInstructionExecutors) Add added in v0.4.1

func (receiver *RwxInstructionExecutors) Add(
	rwxInstructionExecutor *RwxInstructionExecutor,
) *RwxInstructionExecutors

Add skips nil

func (*RwxInstructionExecutors) Adds added in v0.4.1

func (receiver *RwxInstructionExecutors) Adds(
	rwxInstructionExecutors ...*RwxInstructionExecutor,
) *RwxInstructionExecutors

Adds skips nil

func (*RwxInstructionExecutors) ApplyOnPath added in v0.4.1

func (receiver *RwxInstructionExecutors) ApplyOnPath(location string) error

func (*RwxInstructionExecutors) ApplyOnPaths added in v0.4.1

func (receiver *RwxInstructionExecutors) ApplyOnPaths(locations []string) error

func (*RwxInstructionExecutors) ApplyOnPathsPtr added in v0.5.4

func (receiver *RwxInstructionExecutors) ApplyOnPathsPtr(locations *[]string) error

func (*RwxInstructionExecutors) Count added in v0.4.1

func (receiver *RwxInstructionExecutors) Count() int

func (*RwxInstructionExecutors) HasAnyItem added in v0.4.1

func (receiver *RwxInstructionExecutors) HasAnyItem() bool

func (*RwxInstructionExecutors) HasIndex added in v0.4.1

func (receiver *RwxInstructionExecutors) HasIndex(index int) bool

func (*RwxInstructionExecutors) IsEmpty added in v0.4.1

func (receiver *RwxInstructionExecutors) IsEmpty() bool

func (*RwxInstructionExecutors) Items added in v0.4.1

func (receiver *RwxInstructionExecutors) Items() *[]*RwxInstructionExecutor

func (*RwxInstructionExecutors) LastIndex added in v0.4.1

func (receiver *RwxInstructionExecutors) LastIndex() int

func (*RwxInstructionExecutors) Length added in v0.4.1

func (receiver *RwxInstructionExecutors) Length() int

func (*RwxInstructionExecutors) VerifyRwxModifiers added in v0.6.2

func (receiver *RwxInstructionExecutors) VerifyRwxModifiers(
	isContinueOnErr,
	isRecursiveIgnore bool,
	locations []string,
) error

type RwxMatchingStatus added in v0.6.2

type RwxMatchingStatus struct {
	RwxMismatchInfos         []*RwxMismatchInfo
	MissingOrPathsWithIssues []string
	IsAllMatching            bool
	Error                    error
}

func EmptyRwxMatchingStatus added in v0.6.2

func EmptyRwxMatchingStatus() *RwxMatchingStatus

func InvalidRwxMatchingStatus added in v0.6.2

func InvalidRwxMatchingStatus(err error) *RwxMatchingStatus

func (*RwxMatchingStatus) CreateErrFinalError added in v0.6.2

func (it *RwxMatchingStatus) CreateErrFinalError() error

func (*RwxMatchingStatus) MissingFilesToString added in v0.6.2

func (it *RwxMatchingStatus) MissingFilesToString() string

type RwxMismatchInfo added in v0.6.2

type RwxMismatchInfo struct {
	FilePath          string
	Expecting, Actual string
}

type RwxVariableWrapper added in v0.4.4

type RwxVariableWrapper struct {
	Owner, Group, Other VarAttribute
	// contains filtered or unexported fields
}

func NewRwxVariableWrapper added in v0.6.2

func NewRwxVariableWrapper(partialRwx string) (*RwxVariableWrapper, error)

NewRwxVariableWrapper partialRwx can be any length in between 0-10 (rest will be fixed by wildcard)

rwxPartial:

  • "-rwx" will be "-rwx******"
  • "-rwxr-x" will be "-rwxr-x***"
  • "-rwxr-x" will be "-rwxr-x***"

func ParseRwxInstructionToVarWrapper added in v0.4.1

func ParseRwxInstructionToVarWrapper(
	rwxInstruction *chmodins.RwxInstruction,
) (
	*RwxVariableWrapper, error,
)

func ParseRwxOwnerGroupOtherToRwxVariableWrapper added in v0.4.4

func ParseRwxOwnerGroupOtherToRwxVariableWrapper(
	rwxOwnerGroupOther *chmodins.RwxOwnerGroupOther,
) (
	*RwxVariableWrapper, error,
)

func (*RwxVariableWrapper) ApplyRwxOnLocations added in v0.6.3

func (varWrapper *RwxVariableWrapper) ApplyRwxOnLocations(
	isContinueOnError,
	isSkipOnInvalid bool,
	locations []string,
) error

func (*RwxVariableWrapper) Clone added in v0.5.4

func (varWrapper *RwxVariableWrapper) Clone() *RwxVariableWrapper

func (*RwxVariableWrapper) HasWildcard added in v0.6.2

func (varWrapper *RwxVariableWrapper) HasWildcard() bool

func (*RwxVariableWrapper) IsEqualPartialFullRwx added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualPartialFullRwx(
	fullRwx string,
) bool

IsEqualPartialFullRwx will compare with concrete FullRwx (10 chars) where wildcard will be ignore during compare

func (*RwxVariableWrapper) IsEqualPartialRwxPartial added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualPartialRwxPartial(
	rwxPartial string,
) bool

IsEqualPartialRwxPartial will make the partial to full rwx and then calls IsEqualPartialFullRwx partialRwx can be any length in between 0-10 (rest will be fixed by wildcard)

rwxPartial:

  • "-rwx" will be "-rwx******"
  • "-rwxr-x" will be "-rwxr-x***"
  • "-rwxr-x" will be "-rwxr-x***"

func (*RwxVariableWrapper) IsEqualPartialUsingFileMode added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualPartialUsingFileMode(
	mode os.FileMode,
) bool

IsEqualPartialUsingFileMode will compare with concrete FullRwx (10 chars) where wildcard will be ignore during compare

func (*RwxVariableWrapper) IsEqualPtr added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualPtr(next *RwxVariableWrapper) bool

func (*RwxVariableWrapper) IsEqualRwxWrapperPtr added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualRwxWrapperPtr(
	rwxWrapper *RwxWrapper,
) bool

IsEqualRwxWrapperPtr returns by sending to IsEqualPartialFullRwx

Returns false on nil.

func (*RwxVariableWrapper) IsEqualUsingFileInfo added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualUsingFileInfo(
	fileInfo os.FileInfo,
) bool

IsEqualUsingFileInfo returns by sending to IsEqualPartialFullRwx

Returns false on nil.

func (*RwxVariableWrapper) IsEqualUsingFileMode added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualUsingFileMode(
	fileMode os.FileMode,
) bool

IsEqualUsingFileMode returns by sending to IsEqualPartialFullRwx

Returns false on nil.

func (*RwxVariableWrapper) IsEqualUsingLocation added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsEqualUsingLocation(
	location string,
) bool

IsEqualUsingLocation returns by sending to IsEqualPartialFullRwx

Returns false on non exist.

func (*RwxVariableWrapper) IsFixedType added in v0.4.4

func (varWrapper *RwxVariableWrapper) IsFixedType() bool

func (*RwxVariableWrapper) IsGroupPartialMatch added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsGroupPartialMatch(rwx string) bool

func (*RwxVariableWrapper) IsMismatchPartialFullRwx added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsMismatchPartialFullRwx(
	fullRwx string,
) bool

IsMismatchPartialFullRwx returns revert of IsEqualPartialFullRwx

fullRwx (10 chars) where wildcard will be ignore during compare

func (*RwxVariableWrapper) IsOtherPartialMatch added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsOtherPartialMatch(rwx string) bool

func (*RwxVariableWrapper) IsOwnerPartialMatch added in v0.6.2

func (varWrapper *RwxVariableWrapper) IsOwnerPartialMatch(rwx string) bool

func (*RwxVariableWrapper) RwxMatchingStatus added in v0.6.2

func (varWrapper *RwxVariableWrapper) RwxMatchingStatus(
	isContinueOnError,
	isSkipOnInvalid bool,
	locations []string,
) *RwxMatchingStatus

func (*RwxVariableWrapper) String added in v0.6.2

func (varWrapper *RwxVariableWrapper) String() string

func (*RwxVariableWrapper) ToCompileFixedPtr added in v0.4.4

func (varWrapper *RwxVariableWrapper) ToCompileFixedPtr() *RwxWrapper

func (*RwxVariableWrapper) ToCompileWrapper added in v0.4.4

func (varWrapper *RwxVariableWrapper) ToCompileWrapper(fixed *RwxWrapper) RwxWrapper

ToCompileWrapper if Fixed type then fixed input can be nil.

func (*RwxVariableWrapper) ToCompileWrapperPtr added in v0.4.4

func (varWrapper *RwxVariableWrapper) ToCompileWrapperPtr(fixed *RwxWrapper) *RwxWrapper

ToCompileWrapperPtr if Fixed type then fixed input can be nil.

func (*RwxVariableWrapper) ToCompileWrapperUsingLocationPtr added in v0.5.5

func (varWrapper *RwxVariableWrapper) ToCompileWrapperUsingLocationPtr(location string) (*RwxWrapper, error)

func (*RwxVariableWrapper) ToString added in v0.6.2

func (varWrapper *RwxVariableWrapper) ToString(isIncludeHyphen bool) string

type RwxWrapper added in v0.4.4

type RwxWrapper struct {
	Owner, Group, Other Attribute
}

func GetExistingChmodRwxWrapper added in v0.5.0

func GetExistingChmodRwxWrapper(
	filePath string,
) (RwxWrapper, error)

func GetExistingChmodRwxWrapperMustPtr added in v0.5.0

func GetExistingChmodRwxWrapperMustPtr(
	filePath string,
) *RwxWrapper

func GetExistingChmodRwxWrapperPtr added in v0.5.0

func GetExistingChmodRwxWrapperPtr(
	filePath string,
) (*RwxWrapper, error)

func New

func New(mode string) (RwxWrapper, error)

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) RwxWrapper

func NewUsingAttrs

func NewUsingAttrs(owner, group, other Attribute) RwxWrapper

func NewUsingByte

func NewUsingByte(owner, group, other byte) RwxWrapper

NewUsingByte each byte should not be more than 7

func NewUsingBytes

func NewUsingBytes(allBytes [3]byte) RwxWrapper

NewUsingBytes each byte should not be more than 7

func NewUsingFileMode

func NewUsingFileMode(fileMode os.FileMode) RwxWrapper

func NewUsingFileModePtr added in v0.4.1

func NewUsingFileModePtr(fileMode os.FileMode) *RwxWrapper

func NewUsingHyphenedRwxFullString added in v0.4.4

func NewUsingHyphenedRwxFullString(hyphenedRwxRwxRwx string) (RwxWrapper, error)

NewUsingHyphenedRwxFullString Format "-rwxrwxrwx"

eg. owener all enabled only "-rwx------"

eg. group all enabled only "----rwx---"

length must be 10 always.

Reference: https://ss64.com/bash/chmod.html

func NewUsingRwxFullString added in v0.4.4

func NewUsingRwxFullString(rwxFullStringWithoutHyphen string) (RwxWrapper, error)

NewUsingRwxFullString Format "rwxrwxrwx"

eg. owener all enabled only "rwx------"

eg. group all enabled only "---rwx---"

length must be 9 always.

func NewUsingRwxOwnerGroupOther added in v0.4.4

func NewUsingRwxOwnerGroupOther(
	rwxOwnerGroupOther *chmodins.RwxOwnerGroupOther,
) (RwxWrapper, error)

func NewUsingVariant

func NewUsingVariant(variant Variant) (RwxWrapper, error)

func NewUsingVariantPtr added in v0.5.6

func NewUsingVariantPtr(variant Variant) (*RwxWrapper, error)

func (*RwxWrapper) ApplyChmod added in v0.4.4

func (it *RwxWrapper) ApplyChmod(
	isSkipOnInvalid bool,
	fileOrDirectoryPath string,
) error

func (*RwxWrapper) ApplyLinuxChmodOnMany added in v0.5.5

func (it *RwxWrapper) ApplyLinuxChmodOnMany(
	condition *chmodins.Condition,
	locations ...string,
) error

func (*RwxWrapper) ApplyRecursive added in v0.8.0

func (it *RwxWrapper) ApplyRecursive(
	isSkipOnInvalid bool,
	location string,
) error

ApplyRecursive skip if it is a non dir path

func (*RwxWrapper) Bytes added in v0.4.4

func (it *RwxWrapper) Bytes() [3]byte

Bytes

return rwx, (Owner)(Group)(Other) byte values under 1-7

func (*RwxWrapper) Clone added in v0.5.4

func (it *RwxWrapper) Clone() *RwxWrapper

func (*RwxWrapper) HasChmod added in v0.4.4

func (it *RwxWrapper) HasChmod(location string) bool

func (*RwxWrapper) IsEqualFileMode added in v0.6.2

func (it *RwxWrapper) IsEqualFileMode(
	mode os.FileMode,
) bool

func (*RwxWrapper) IsEqualPtr added in v0.6.2

func (it *RwxWrapper) IsEqualPtr(
	next *RwxWrapper,
) bool

func (*RwxWrapper) IsEqualVarWrapper added in v0.6.2

func (it *RwxWrapper) IsEqualVarWrapper(
	rwxVariableWrapper *RwxVariableWrapper,
) bool

IsEqualVarWrapper if rwxVariableWrapper nil then returns false

func (*RwxWrapper) IsRwxEqualFileInfo added in v0.6.2

func (it *RwxWrapper) IsRwxEqualFileInfo(
	fileInfo os.FileInfo,
) bool

IsRwxEqualFileInfo if fileInfo nil then returns false

func (*RwxWrapper) IsRwxEqualLocation added in v0.6.2

func (it *RwxWrapper) IsRwxEqualLocation(
	location string,
) bool

func (*RwxWrapper) IsRwxFullEqual added in v0.6.2

func (it *RwxWrapper) IsRwxFullEqual(
	rwxFull string,
) bool

func (*RwxWrapper) LinuxApplyRecursive added in v0.4.5

func (it *RwxWrapper) LinuxApplyRecursive(
	isSkipOnInvalid bool,
	location string,
) error

LinuxApplyRecursive skip if it is a non dir path

func (*RwxWrapper) MustApplyChmod added in v0.4.4

func (it *RwxWrapper) MustApplyChmod(fileOrDirectoryPath string)

func (*RwxWrapper) String added in v0.4.4

func (it *RwxWrapper) String() string

func (*RwxWrapper) ToCompiledOctalBytes3Digits added in v0.4.4

func (it *RwxWrapper) ToCompiledOctalBytes3Digits() [3]byte

ToCompiledOctalBytes3Digits return '0'(Owner + '0')(Group + '0')(Other + '0') eg. 777, 555, 755 NOT rwx return

owner -> (0 - 7 value)
group -> (0 - 7 value)
other -> (0 - 7 value)

func (*RwxWrapper) ToCompiledOctalBytes4Digits added in v0.4.4

func (it *RwxWrapper) ToCompiledOctalBytes4Digits() [4]byte

ToCompiledOctalBytes4Digits return 0rwx, '0'(Owner + '0')(Group + '0')(Other + '0') eg. 0777, 0555, 0755 NOT 0rwx

func (*RwxWrapper) ToCompiledSplitValues added in v0.4.4

func (it *RwxWrapper) ToCompiledSplitValues() (owner, group, other byte)

ToCompiledSplitValues return

owner -> (0 - 7 value)
group -> (0 - 7 value)
other -> (0 - 7 value)
eg. 777, 755 etc

func (*RwxWrapper) ToFileMode added in v0.4.4

func (it *RwxWrapper) ToFileMode() os.FileMode

func (*RwxWrapper) ToFileModeString added in v0.4.4

func (it *RwxWrapper) ToFileModeString() string

ToFileModeString 4 digit string 0rwx, example 0777

func (*RwxWrapper) ToFullRwxValueString added in v0.4.4

func (it *RwxWrapper) ToFullRwxValueString() string

ToFullRwxValueString returns "-rwxrwxrwx"

func (*RwxWrapper) ToFullRwxValueStringExceptHyphen added in v0.6.2

func (it *RwxWrapper) ToFullRwxValueStringExceptHyphen() string

ToFullRwxValueStringExceptHyphen returns "rwxrwxrwx", 9 chars

func (*RwxWrapper) ToFullRwxValuesChars added in v0.4.4

func (it *RwxWrapper) ToFullRwxValuesChars() []byte

ToFullRwxValuesChars "-rwxrwxrwx" Bytes values

func (*RwxWrapper) ToRwxCompiledStr added in v0.4.4

func (it *RwxWrapper) ToRwxCompiledStr() string

ToRwxCompiledStr 3 digit string, example 777

func (*RwxWrapper) ToRwxInstruction added in v0.5.5

func (it *RwxWrapper) ToRwxInstruction(
	condition *chmodins.Condition,
) *chmodins.RwxInstruction

func (*RwxWrapper) ToRwxOwnerGroupOther added in v0.4.4

func (it *RwxWrapper) ToRwxOwnerGroupOther() *chmodins.RwxOwnerGroupOther

func (*RwxWrapper) ToUint32Octal added in v0.4.4

func (it *RwxWrapper) ToUint32Octal() uint32

func (*RwxWrapper) Verify added in v0.4.4

func (it *RwxWrapper) Verify(location string) error

func (*RwxWrapper) VerifyPaths added in v0.4.4

func (it *RwxWrapper) VerifyPaths(location *[]string, isContinueOnError bool) error

type SingleRwx added in v0.5.5

type SingleRwx struct {
	// Rwx Index Values
	//  - 0: 'r'/'*'/'-'
	//  - 1: 'w'/'*'/'-'
	//  - 2: 'x'/'*'/'-'
	// Examples can be :
	//  - "rwx" or
	//  - "*wx" or
	//  - "rw*" or
	//  - "***"
	//
	// Length must be 3. Not more not less.
	Rwx       string
	ClassType chmodclasstype.Variant
}

func NewSingleRwx added in v0.5.5

func NewSingleRwx(
	rwx string,
	classType chmodclasstype.Variant,
) (*SingleRwx, error)

func (*SingleRwx) ApplyOnMany added in v0.5.5

func (receiver *SingleRwx) ApplyOnMany(
	condition *chmodins.Condition,
	locations ...string,
) error

func (*SingleRwx) ToDisabledRwxWrapper added in v0.5.5

func (receiver *SingleRwx) ToDisabledRwxWrapper() (*RwxWrapper, error)

func (*SingleRwx) ToRwxInstruction added in v0.5.5

func (receiver *SingleRwx) ToRwxInstruction(
	conditionalIns *chmodins.Condition,
) *chmodins.RwxInstruction

func (*SingleRwx) ToRwxOwnerGroupOther added in v0.5.5

func (receiver *SingleRwx) ToRwxOwnerGroupOther() *chmodins.RwxOwnerGroupOther

func (*SingleRwx) ToRwxWrapper added in v0.5.5

func (receiver *SingleRwx) ToRwxWrapper() (*RwxWrapper, error)

func (*SingleRwx) ToVarRwxWrapper added in v0.5.5

func (receiver *SingleRwx) ToVarRwxWrapper() (*RwxVariableWrapper, error)

type VarAttribute added in v0.4.1

type VarAttribute struct {
	// contains filtered or unexported fields
}

func ParseRwxToVarAttribute added in v0.4.1

func ParseRwxToVarAttribute(rwx string) (varAttribute *VarAttribute, err error)

func (*VarAttribute) Clone added in v0.5.4

func (varAttribute *VarAttribute) Clone() *VarAttribute

func (*VarAttribute) HasWildcard added in v0.6.2

func (varAttribute *VarAttribute) HasWildcard() bool

func (*VarAttribute) IsEqualPtr added in v0.6.2

func (varAttribute *VarAttribute) IsEqualPtr(next *VarAttribute) bool

func (*VarAttribute) IsFixedType added in v0.4.1

func (varAttribute *VarAttribute) IsFixedType() bool

func (*VarAttribute) String added in v0.6.2

func (varAttribute *VarAttribute) String() string

func (*VarAttribute) ToCompileAttr added in v0.4.1

func (varAttribute *VarAttribute) ToCompileAttr(fixed *Attribute) Attribute

ToCompileAttr if fixed type then fixed param can be nil

func (*VarAttribute) ToCompileFixAttr added in v0.4.1

func (varAttribute *VarAttribute) ToCompileFixAttr() *Attribute

ToCompileFixAttr must check IsFixedType, before calling.

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"
	X111                                Variant = "111"
	X222                                Variant = "222"
	X333                                Variant = "333"
	X444                                Variant = "444"
	X555                                Variant = "555"
	X644                                Variant = "644"
	X655                                Variant = "655"
	X666                                Variant = "666"
	X677                                Variant = "677"
	X711                                Variant = "711"
	X722                                Variant = "722"
	X733                                Variant = "733"
	X744                                Variant = "744"
	X755                                Variant = "755"
	X766                                Variant = "766"
	X777                                Variant = "777"
)

func (*Variant) ExpandOctalByte added in v0.5.6

func (variant *Variant) ExpandOctalByte() (r7, w7, x7 byte)

func (*Variant) String

func (variant *Variant) String() string

func (*Variant) ToWrapper

func (variant *Variant) ToWrapper() (RwxWrapper, error)

func (*Variant) ToWrapperPtr added in v0.5.6

func (variant *Variant) ToWrapperPtr() (*RwxWrapper, error)

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL