Documentation ¶
Index ¶
- func DirExists(fs utilfs.Filesystem, path string) (bool, error)
- func EnsureDir(fs utilfs.Filesystem, path string) error
- func EnsureFile(fs utilfs.Filesystem, path string) error
- func FileExists(fs utilfs.Filesystem, path string) (bool, error)
- func GetAllFiles(dirPth string) (files []string, err error)
- func ReadFileWithDir(dir string, filename string) ([]byte, error)
- func ReplaceDir(fs utilfs.Filesystem, path string, files map[string]string) error
- func ReplaceFile(fs utilfs.Filesystem, path string, data []byte) error
- func WriteFileWithDir(dir string, filename string, data []byte, perm os.FileMode) error
- func WriteTempDir(fs utilfs.Filesystem, path string, files map[string]string) (tmpPath string, retErr error)
- func WriteTmpFile(fs utilfs.Filesystem, path string, data []byte) (tmpPath string, retErr error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirExists ¶
func DirExists(fs utilfs.Filesystem, path string) (bool, error)
DirExists returns true if a directory exists at `path`, false if `path` does not exist, otherwise an error
func EnsureDir ¶
func EnsureDir(fs utilfs.Filesystem, path string) error
EnsureDir ensures that a directory exists at `path`, and if it must create the directory any necessary parent directories will also be created and the new directory will be empty.
func EnsureFile ¶
func EnsureFile(fs utilfs.Filesystem, path string) error
EnsureFile ensures that a regular file exists at `path`, and if it must create the file any necessary parent directories will also be created and the new file will be empty.
func FileExists ¶
func FileExists(fs utilfs.Filesystem, path string) (bool, error)
FileExists returns true if a regular file exists at `path`, false if `path` does not exist, otherwise an error
func GetAllFiles ¶ added in v1.7.0
GetAllFiles gets all files in the specified directory, including files in subdirectories
func ReadFileWithDir ¶ added in v1.3.1
ReadFileWithDir reads the file named by filename in dir and returns the contents.
func ReplaceDir ¶
ReplaceDir replaces the contents of the dir at `path` with `files` by writing to a tmp dir in the same dir as `path` and renaming the tmp dir over `path`. The dir does not have to exist to use ReplaceDir.
func ReplaceFile ¶
func ReplaceFile(fs utilfs.Filesystem, path string, data []byte) error
ReplaceFile replaces the contents of the file at `path` with `data` by writing to a tmp file in the same dir as `path` and renaming the tmp file over `path`. The file does not have to exist to use ReplaceFile, but the parent directory must exist. Note ReplaceFile calls fsync.
func WriteFileWithDir ¶ added in v1.3.1
WriteFileWithDir writes data to a file named by filename in dir.
func WriteTempDir ¶
func WriteTempDir(fs utilfs.Filesystem, path string, files map[string]string) (tmpPath string, retErr error)
WriteTempDir creates a temporary dir at `path`, writes `files` into it, and fsyncs all the files The keys of `files` represent file names. These names must not: - be empty - be a path that contains more than the base name of a file (e.g. foo/bar is invalid, as is /bar) - match `.` or `..` exactly - be longer than 255 characters The above validation rules are based on atomic_writer.go, though in this case are more restrictive because we only allow a flat hierarchy.
func WriteTmpFile ¶
WriteTmpFile creates a temporary file at `path`, writes `data` into it, and fsyncs the file Expects the parent directory to exist.
Types ¶
This section is empty.