osutil

package
v0.6.20 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ModeUserRW = 0600 // rw-------
View Source
const ModeUserRWX = 0700 // rwx------
View Source
const ModeUserRWXGroupRX = 0750 // rwxr-x---

Variables

View Source
var ErrUnsupportedFileType = errors.New("unsupported file type")

ErrUnsupportedFileType is returned when attempting to copy a file type that's not supported.

Functions

func CopyDir added in v0.6.16

func CopyDir(ctx context.Context, srcDir, dstDir string) error

CopyDir recursively copies a directory from 'srcDir' to 'dstDir', preserving soft links. All regular files will be hard copied. Note that file attributes are not preserved, so this should only be used when the folder contents are required in the original structure. This implementation is based on [1].

[1] https://github.com/moby/moby/blob/master/daemon/graphdriver/copy/copy.go

func CopyFile added in v0.6.16

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

CopyFile is a utility function for copying an 'io.Reader' to a new file created with the specified 'os.FileMode'.

func EnsureDir added in v0.6.11

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

EnsureDir verifies that the specified path exists, is a directory, and has the specified permission bits set.

func ForceRename

func ForceRename(oldPath, newPath string) error

Moves a file or directory from one path to a new path.

NOTE: This will overwrite any file or directory which already exists at the 'newPath' parameter.

func ModeOf

func ModeOf(path string) (fs.FileMode, error)

ModeOf returns the file mode of the specified file.

func SizeOf

func SizeOf(path string) (uint64, error)

SizeOf returns the size of the specified file in bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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