fileutil

package
v0.0.0-...-fddb751 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(dst, src string, srcFS fs.FS) error

CopyDir recursively copies the directory at path src to a new directory at path dst. If a symlink is encountered along the way, its link is copied verbatim and installed in the destination directory hierarchy, as in CopySymlink.

If srcFS != nil, then src is assumed to be a path within srcFS.

dst and directories under dst may not retain the permissions of src or the corresponding directories under src. Instead, we always set the permissions of the new directories to 0755.

func CopyFile

func CopyFile(dst, src string, sfinfo fs.FileInfo, srcFS fs.FS) error

CopyFile copies a file at path src to dst. sfinfo is the os.FileInfo associated with the file at path src and must be derived from it. sfinfo may be nil, in which case the file at src is queried for its os.FileInfo, and symbolic links are followed.

In effect, sfinfo is just an optimization to avoid querying the path for the os.FileInfo more than necessary.

Thus, CopyFile always copies the bytes of the file at src to a new file created at dst with the same file mode as the old one.

If srcFS != nil, then src is assumed to be a path within srcFS.

Returns a non-nil error if copying or acquiring the os.FileInfo for the file fails.

func FileExists

func FileExists(path string) (bool, error)

FileExists returns true if a file or directory exists at the specified path, otherwise it returns false. If an error is encountered while checking, an error is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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