code-intelligence.com/cifuzz@v0.40.0/internal/cmdutils/validate.go (about)

     1  package cmdutils
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  
     7  	"github.com/pkg/errors"
     8  )
     9  
    10  // ValidateSeedCorpusDirs checks if the seed dirs exist and can be
    11  // accessed and ensures that the paths are absolute
    12  func ValidateSeedCorpusDirs(seedCorpusDirs []string) ([]string, error) {
    13  	for i, d := range seedCorpusDirs {
    14  		_, err := os.Stat(d)
    15  		if err != nil {
    16  			return nil, errors.WithStack(err)
    17  		}
    18  		seedCorpusDirs[i], err = filepath.Abs(d)
    19  		if err != nil {
    20  			return nil, errors.WithStack(err)
    21  		}
    22  	}
    23  	return seedCorpusDirs, nil
    24  }