Add FileExists and DirExists for checking what is at a path #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Asking whether a path holds a file or a directory is a constant need in
command-line programs, and the standard library only offers
os.Statplus anerror test, which people regularly get wrong by treating every error as "not
there" or by forgetting that a directory is not a file. The repo already has
MkdirpandCopyFile, so these two belong in the same drawer.Definition of done:
FileExists(path string) boolreports whether the pathexists and is a regular file, and
DirExists(path string) boolreports whetherit exists and is a directory, with both returning false for anything they
cannot look at. They have doc comments and table-driven tests, run against a
temporary directory, covering an existing file, an existing directory, a path
that does not exist, a path whose parent does not exist, and an empty path.
Model: opus-5