gitlab.com/evatix-go/core@v1.3.55/chmodhelper/DirFilesRwxPermission.go (about) 1 package chmodhelper 2 3 import ( 4 "os" 5 "path" 6 7 "gitlab.com/evatix-go/core/chmodhelper/chmodins" 8 "gitlab.com/evatix-go/core/constants" 9 "gitlab.com/evatix-go/core/coredata/corestr" 10 "gitlab.com/evatix-go/core/errcore" 11 ) 12 13 type DirFilesWithRwxPermission struct { 14 DirWithFiles 15 ApplyRwx chmodins.RwxOwnerGroupOther 16 } 17 18 func (it *DirFilesWithRwxPermission) GetPaths() []string { 19 return *it.GetPathsPtr() 20 } 21 22 func (it *DirFilesWithRwxPermission) GetPathsPtr() *[]string { 23 collection := corestr.New.Collection.Cap(constants.ArbitraryCapacity50) 24 25 for _, file := range it.Files { 26 compiledPath := path.Join(it.Dir, file) 27 collection.Add(compiledPath) 28 } 29 30 return collection.ListPtr() 31 } 32 33 func (it *DirFilesWithRwxPermission) GetFilesChmodMap() *corestr.Hashmap { 34 files := it.GetPathsPtr() 35 36 hashmap, err := GetFilesChmodRwxFullMap(*files) 37 38 errcore.SimpleHandleErr( 39 err, 40 "GetFilesChmodMap() failed to retrive hashmap from file paths") 41 42 return hashmap 43 } 44 45 func (it *DirFilesWithRwxPermission) CreatePaths( 46 isRemoveBeforeCreate bool, 47 ) error { 48 return CreateDirFilesWithRwxPermission( 49 isRemoveBeforeCreate, 50 it) 51 } 52 53 func (it *DirFilesWithRwxPermission) CreatePathsUsingFileMode( 54 isRemoveBeforeCreate bool, 55 fileMode os.FileMode, 56 ) error { 57 return it.DirWithFiles.CreatePaths( 58 isRemoveBeforeCreate, 59 fileMode) 60 }