umaskfree

package
v0.0.0-...-c5cf874 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Overview

Package umaskfree provides file system functionality that ignore the umask. As such it is not safe to use otherwise equivalent functions provided by the standard go library concurrently with this package. Users should take care that no other code in their application uses these functions.

Index

Constants

View Source
const DefaultDirPerm fs.FileMode = fs.ModeDir | fs.ModePerm

DefaultDirPerm should be used by callers to use a consistent mode for new directories.

View Source
const DefaultFilePerm fs.FileMode = 0666

DefaultFilePerm should be used by callers to use a consistent file mode for new files.

Variables

View Source
var ErrCopySameFile = errors.New("src and dst must be different")
View Source
var ErrDstFile = errors.New("dst is a file")

Functions

func CopyDirectory

func CopyDirectory(ctx context.Context, dst, src string, onCopy func(dst, src string)) error

CopyDirectory copies the directory src to dst recursively. Copying is aborted when ctx is closed.

Existing files and directories are overwritten. When a directory already exists, additional files are not deleted.

onCopy, when not nil, is called for each file or directory being copied.

func CopyFile

func CopyFile(ctx context.Context, dst, src string) error

CopyFile copies a file from src to dst. When src points to a symbolic link, will copy the symbolic link.

When dst and src are the same file, returns ErrCopySameFile. When ctx is closed, the file is not copied.

func CopyLink(ctx context.Context, dst, src string) error

CopyLink copies a link from src to dst. If dst already exists, it is deleted and then re-created.

func Create

func Create(path string, mode fs.FileMode) (*os.File, error)

Create is like os.Create with an additional mode argument.

func Mkdir

func Mkdir(path string, mode fs.FileMode) error

Mkdir is like os.Mkdir.

func MkdirAll

func MkdirAll(path string, mode fs.FileMode) error

MkdirAll is like os.MkdirAll.

func Touch

func Touch(path string, perm fs.FileMode) error

Touch touches a file. It is similar to the unix 'touch' command.

If the file does not exist, it is created using Create. If the file does exist, its' access and modification times are updated to the current time.

func WriteFile

func WriteFile(path string, data []byte, mode fs.FileMode) error

WriteFile is like os.WriteFile.

Types

This section is empty.

Jump to

Keyboard shortcuts

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