fileutils

package
v0.0.0-...-63b292e Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PathAlreadyExistsError = &os.PathError{Op: "Create", Err: os.ErrExist}

Functions

func CommonPrefix

func CommonPrefix(sep byte, paths ...string) string

CommonPrefix returns common directory path of provided files

func Copy

func Copy(fsys afero.Fs, from, to string) (err error)

Copy copies the file content from source to destination. Tries hard to succeed on various systems by temporarily tweaking directory permissions and removing the destination file when necessary.

func CopyDir

func CopyDir(fs afero.Fs, source, dest string) error

CopyDir copies a directory from source to dest and all of its sub-directories. It doesn't stop if it finds an error during the copy. Returns an error if any.

func CopyFile

func CopyFile(fs afero.Fs, source, dest string) error

CopyFile copies a file from source to dest and returns an error if any.

func MakeDirIfNotExist

func MakeDirIfNotExist(fs afero.Fs, path string) error

MakeDirIfNotExist creates a directory if it does not exist.

func MkFileIfNotExist

func MkFileIfNotExist(fs afero.Fs, path string) error

MkFileIfNotExist creates a file if it does not exist returns an error if the file already exists

func MoveDir

func MoveDir(fs afero.Fs, source, dest string) error

MoveDir moves a directory from source to dest and all of its sub-directories. It doesn't stop if it finds an error during the move. Returns an error if any.

func MoveFile

func MoveFile(fs afero.Fs, src, dst string) error

MoveFile moves file from src to dst. By default the rename filesystem system call is used. If src and dst point to different volumes the file copy is used as a fallback

func MoveFileMany

func MoveFileMany(ctx context.Context, fs afero.Fs, src []string, dst string) []error

MoveFileMany moves files from src into dst. By default the rename filesystem system call is used. If src and dst point to different volumes the file copy is used as a fallback

func MoveOrCopy

func MoveOrCopy(fs afero.Fs, src, dst string) error

MoveOrCopy moves or copies a file or directory from src to dst. Both src and dst must be absolute paths. A rename is attempted but if it fails a copy operation is performed.

func Remove

func Remove(ctx context.Context, fs afero.Fs, file string) error

Remove removes a file or directory If the file is a directory, this removes the directory and any children it contains.

func RemoveMany

func RemoveMany(ctx context.Context, fs afero.Fs, files []string) []error

RemoveMany removes many files and/or directories If any path points to a directory, it and all children will be removed.

func RenameOrCopy

func RenameOrCopy(fsys afero.Fs, from, to string) error

RenameOrCopy renames a file, leaving source file intact in case of failure. Tries hard to succeed on various systems by temporarily tweaking directory permissions and removing the destination file when necessary.

Types

This section is empty.

Jump to

Keyboard shortcuts

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