gitlab.com/evatix-go/core@v1.3.55/chmodhelper/GetPathsChmodsHashmap.go (about)

     1  package chmodhelper
     2  
     3  import (
     4  	"gitlab.com/evatix-go/core/coredata/corestr"
     5  	"gitlab.com/evatix-go/core/errcore"
     6  )
     7  
     8  // GetFilesChmodRwxFullMap returns filePath -> "-rwxrwxrwx"
     9  func GetFilesChmodRwxFullMap(
    10  	requestedPaths []string,
    11  ) (filePathToRwxMap *corestr.Hashmap, err error) {
    12  	length := len(requestedPaths)
    13  	hashmap := corestr.New.Hashmap.Cap(length)
    14  
    15  	if length == 0 {
    16  		return hashmap, nil
    17  	}
    18  
    19  	var sliceErr []string
    20  
    21  	for _, filePath := range requestedPaths {
    22  		fileMode, err2 := GetExistingChmod(filePath)
    23  
    24  		if err2 != nil {
    25  			sliceErr = append(sliceErr, err2.Error())
    26  
    27  			continue
    28  		}
    29  
    30  		hashmap.AddOrUpdate(filePath, fileMode.String())
    31  	}
    32  
    33  	return hashmap, errcore.SliceErrorDefault(&sliceErr)
    34  }