fsext

package
v3.43.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDir

func DefaultDir(entrypoint, dir string) string

DefaultDir will return the default directory given an entrypoint or directory. If the directory is set, it will ensure it is an absolute path and return it. If the entrypoint is set, but the directory is not, it will leave the directory blank. If both are empty, it will default the directory to the current working directory.

func Search(entrypoint, dir string, possibleFilenames []string) (string, string, error)

Search will look for files with the given possible filenames using the given entrypoint and directory. If the entrypoint is set, it will check if the entrypoint matches a file or if it matches a directory containing one of the possible filenames. Otherwise, it will walk up the file tree starting at the given directory and perform a search in each directory for the possible filenames until it finds a match or reaches the root directory. If the entrypoint and directory are both empty, it will default the directory to the current working directory and perform a recursive search starting there. If a match is found, the absolute path to the file will be returned with its directory. If no match is found, an error will be returned.

func SearchPath

func SearchPath(path string, possibleFilenames []string) (string, error)

Search will check if a file at the given path exists or not. If it does, it will return the path to it. If it does not, it will search for any files at the given path with any of the given possible names. If any of these match a file, the first matching path will be returned. If no files are found, an error will be returned.

func SearchPathRecursively

func SearchPathRecursively(path string, possibleFilenames []string) (string, error)

SearchRecursively will check if a file at the given path exists by calling the exists function. If a file is not found, it will walk up the directory tree calling the Search function until it finds a file or reaches the root directory. On supported operating systems, it will also check if the user ID of the directory changes and abort if it does.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL