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

     1  package chmodhelper
     2  
     3  import "gitlab.com/evatix-go/core/errcore"
     4  
     5  func GetExistingChmodRwxWrappers(
     6  	isContinueOnError bool,
     7  	locations ...string,
     8  ) (filePathToRwxWrapper map[string]*RwxWrapper, err error) {
     9  	results := make(
    10  		map[string]*RwxWrapper,
    11  		len(locations))
    12  
    13  	if len(locations) == 0 {
    14  		return results, nil
    15  	}
    16  
    17  	if isContinueOnError {
    18  		var sliceErr []string
    19  
    20  		for _, location := range locations {
    21  			wrapperPtr, err2 := GetExistingChmodRwxWrapperPtr(
    22  				location)
    23  
    24  			if err2 != nil {
    25  				sliceErr = append(
    26  					sliceErr,
    27  					err2.Error())
    28  			} else {
    29  				results[location] = wrapperPtr
    30  			}
    31  		}
    32  
    33  		return results, errcore.SliceToError(sliceErr)
    34  	}
    35  
    36  	// immediate exit
    37  	for _, location := range locations {
    38  		wrapperPtr, err2 := GetExistingChmodRwxWrapperPtr(
    39  			location)
    40  
    41  		if err2 != nil {
    42  			return results, err2
    43  		} else {
    44  			results[location] = wrapperPtr
    45  		}
    46  	}
    47  
    48  	return results, nil
    49  }