fileutils

package
v2.0.1-a-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrivateFileMode grants owner to read/write a file.
	PrivateFileMode = 0600
	// PrivateDirMode means read and execute access for everyone and also write access for the owner of the directory.
	PrivateDirMode = 0755
)

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(path string) error

DeleteFile deletes a regular file not a directory.

func GetFreeSpace

func GetFreeSpace(path string) (unit.Bytes, error)

GetFreeSpace gets the free disk space of the path.

func GetTotalAndFreeSpace

func GetTotalAndFreeSpace(path string) (unit.Bytes, unit.Bytes, error)

func GetTotalSpace

func GetTotalSpace(path string) (unit.Bytes, error)

GetTotalSpace

func GetUsedSpace

func GetUsedSpace(path string) (unit.Bytes, error)

GetUsedSpace

func IsDir

func IsDir(path string) bool

func IsEmptyDir

func IsEmptyDir(path string) (bool, error)

func IsRegular

func IsRegular(path string) bool
func IsSymbolicLink(name string) bool
func Link(oldname string, newname string) error

Link creates a hard link pointing to oldname named newname for a file.

func MkdirAll

func MkdirAll(dir string) error

MkdirAll creates a directory named path with 0755 perm.

func MoveFile

func MoveFile(src string, dst string) error

MoveFile moves the file src to dst.

func OpenFile

func OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)

OpenFile opens a file. If the parent directory of the file isn't exist, it will create the directory with 0755 perm.

func PathExist

func PathExist(path string) bool

PathExist reports whether the path is exist. Any error, from os.Lstat, will return false.

func SymbolicLink(oldname string, newname string) error

SymbolicLink creates newname as a symbolic link to oldname.

Types

type FileLock

type FileLock struct {
	// contains filtered or unexported fields
}

FileLock defines a file lock implemented by syscall.Flock. Locks created by flock() are associated with an open file description. This means that duplicate file descriptors (created by, for example, fork or dup) refer to the same lock, and this lock may be modified or released using any of these file descriptors. Furthermore, the lock is released either by an explicit LOCK_UN operation on any of these duplicate file descriptors, or when all such file descriptors have been closed.

func NewFileLock

func NewFileLock(path string) (*FileLock, error)

func (*FileLock) Lock

func (locker *FileLock) Lock() error

func (*FileLock) TryLock

func (locker *FileLock) TryLock() error

func (*FileLock) Unlock

func (locker *FileLock) Unlock() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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