Cleaning up the codebase.

This commit is contained in:
2023-05-04 23:21:07 -07:00
parent 8b2d10209e
commit 74ce7bc58a
16 changed files with 170 additions and 127 deletions

View File

@@ -1,10 +1,11 @@
//go:build !windows
// +build !windows
// Package fileutil contains common file functions.
package fileutil
import (
"os"
"path/filepath"
"strings"
"golang.org/x/sys/unix"
)
@@ -47,10 +48,3 @@ const (
func Access(path string, mode int) error {
return unix.Access(path, uint32(mode))
}
// ValidateSymlink checks to make sure a symlink exists in some top-level
// directory.
func ValidateSymlink(symlink, topLevel string) bool {
target, err := filepath.EvalSymlinks(symlink)
return strings.HasPrefix(target, topLevel)
}