Documentation ¶
Index ¶
- func CopyFile(c *modulir.Context, source, target string) error
- func CopyFileToDir(c *modulir.Context, source, targetDir string) error
- func EnsureDir(c *modulir.Context, target string) error
- func EnsureSymlink(c *modulir.Context, source, target string) error
- func Exists(file string) bool
- func IsBackup(base string) bool
- func IsHidden(base string) bool
- func IsMeta(base string) bool
- func MustAbs(path string) string
- func ReadDir(c *modulir.Context, source string) ([]string, error)
- func ReadDirCached(c *modulir.Context, source string, opts *ReadDirOptions) ([]string, error)
- func ReadDirWithOptions(c *modulir.Context, source string, opts *ReadDirOptions) ([]string, error)
- type ReadDirOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFileToDir ¶
CopyFileToDir is a shortcut for copy a file from a source path to a target directory.
func EnsureSymlink ¶
EnsureSymlink ensures the existence of a symbolic link that maps a target path to a source path.
func Exists ¶
Exists is a shortcut to check if a file exists. It panics if encountering an unexpected error.
func IsBackup ¶
IsBackup indicates whether a given filename is a backup file (i.e. prefixed by `~`).
func IsHidden ¶
IsHidden indicates whether a given filename is a hidden file (i.e. prefixed by `.`).
func MustAbs ¶
MustAbs is a shortcut variant of filepath.Abs which panics instead of returning an error.
func ReadDir ¶
ReadDir reads files in a directory and returns a list of file paths.
Unlike os.ReadDir, this function skips hidden, "meta" (i.e. prefixed by an underscore), and Vim backup (i.e. suffixed with a tilde) files, and returns a list of full paths (easier to plumb into other functions), and sets up a watch on the listed source.
func ReadDirCached ¶
ReadDirCached is the same as ReadDirWithOptions, but it caches results for some amount of time to make it faster. The downside of this of course is that we occasionally get a stale cache when a new file is added and don't see it.
func ReadDirWithOptions ¶
func ReadDirWithOptions(c *modulir.Context, source string, opts *ReadDirOptions, ) ([]string, error)
ReadDirWithOptions reads files in a directory and returns a list of file paths.
Unlike ReadDir, its behavior can be tweaked.
Types ¶
type ReadDirOptions ¶
type ReadDirOptions struct { // RecurseDir tells the function to recurse into subdirectories. RecurseDirs bool // ShowBackup tells the function to not skip backup files like those // produced by Vim. These are suffixed with a tilde '~'. ShowBackup bool // ShowDirs tell the function not to skip directories. ShowDirs bool // ShowHidden tells the function to not skip hidden files (prefixed with a // dot '.'). ShowHidden bool // ShowMeta tells the function to not skip so-called "meta" files // (prefixed with an underscore '_'). ShowMeta bool }
ReadDirOptions are options for ReadDirWithOptions.