func cachedDumpFile()

in cmd/seccomp-profiler/main.go [218:242]


func cachedDumpFile(binary string) (string, error) {
	abs, err := filepath.Abs(binary)
	if err != nil {
		return "", err
	}

	h := sha256.New()
	if _, err := h.Write([]byte(abs)); err != nil {
		return "", err
	}
	hash := hex.EncodeToString(h.Sum(nil))
	hash = hash[:10]

	usr, err := user.Current()
	if err != nil {
		return "", err
	}

	dumpDir := filepath.Join(usr.HomeDir, ".seccomp-profiler")
	if err := os.MkdirAll(dumpDir, 0o700); err != nil {
		return "", err
	}

	return filepath.Join(dumpDir, filepath.Base(binary)+"-"+hash), nil
}