fsutil

package
v0.0.0-...-b60b6a8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilePermUserExe  = 0100
	FilePermGroupExe = 0010
	FilePermOtherExe = 0001
)

File permission bits (execute bits only)

View Source
const (
	FMSticky = 01000
	FMSetgid = 02000
	FMSetuid = 04000
)

Native FileModes for extra flags

View Source
const (
	BitSticky = 1
	BitSetgid = 2
	BitSetuid = 4
)

Native FileMode bits for extra flags

View Source
const FMSpecialBits = os.ModeSticky | os.ModeSetgid | os.ModeSetuid

Native FileMode special bits mask

Variables

View Source
var (
	ErrNoSrcDir                  = errors.New("no source directory path")
	ErrNoDstDir                  = errors.New("no destination directory path")
	ErrSameDir                   = errors.New("source and destination directories are the same")
	ErrSrcDirNotExist            = errors.New("source directory doesn't exist")
	ErrSrcNotDir                 = errors.New("source is not a directory")
	ErrSrcNotRegularFile         = errors.New("source is not a regular file")
	ErrUnsupportedFileObjectType = errors.New("unsupported file object type")
)

Directory and file related errors

Functions

func ArchiveDir

func ArchiveDir(afname string,
	d2aname string,
	trimPrefix string,
	addPrefix string) error

func ArchiveFiles

func ArchiveFiles(afname string,
	files []string,
	removePath bool,
	addPrefix string) error

func CopyDir

func CopyDir(clone bool,
	src, dst string,
	copyRelPath, skipErrors bool,
	excludePatterns []string, ignoreDirNames, ignoreFileNames map[string]struct{}) (error, []error)

CopyDir copies a directory

func CopyDirOnly

func CopyDirOnly(clone bool, src, dst string) error

CopyDirOnly copies a directory without any files

func CopyFile

func CopyFile(clone bool, src, dst string, makeDir bool) error

CopyFile copies the source file system object to the desired destination

func CopyRegularFile

func CopyRegularFile(clone bool, src, dst string, makeDir bool) error

CopyRegularFile copies a regular file

func CopySymlinkFile

func CopySymlinkFile(clone bool, src, dst string, makeDir bool) error

CopySymlinkFile copies a symlink file

func DirExists

func DirExists(target string) bool

DirExists returns true if the target exists and it's a directory

func ExeDir

func ExeDir() string

ExeDir returns the directory information for the application

func Exists

func Exists(target string) bool

Exists returns true if the target file system object exists

func FileDir

func FileDir(fileName string) string

FileDir returns the directory information for the given file

func FileModeExtraBitUnix2Go

func FileModeExtraBitUnix2Go(bit uint32) os.FileMode

FileModeExtraBitUnix2Go converts the standard unix filemode bit for the extra flags to the filemode in Go

func FileModeExtraBitsUnix2Go

func FileModeExtraBitsUnix2Go(bits uint32) os.FileMode

FileModeExtraBitsUnix2Go converts the standard unix filemode bits for the extra flags to the filemode flags in Go

func FileModeExtraUnix2Go

func FileModeExtraUnix2Go(mode uint32) os.FileMode

FileModeExtraUnix2Go converts the standard unix filemode for the extra flags to the Go version

func FileModeIsSetgid

func FileModeIsSetgid(mode os.FileMode) bool

FileModeIsSetgid checks if FileMode has the setgid bit set

func FileModeIsSetuid

func FileModeIsSetuid(mode os.FileMode) bool

FileModeIsSetuid checks if FileMode has the setuid bit set

func FileModeIsSticky

func FileModeIsSticky(mode os.FileMode) bool

FileModeIsSticky checks if FileMode has the sticky bit set

func IsDir

func IsDir(target string) bool

IsDir returns true if the target file system object is a directory

func IsRegularFile

func IsRegularFile(target string) bool

IsRegularFile returns true if the target file system object is a regular file

func IsSymlink(target string) bool

IsSymlink returns true if the target file system object is a symlink

func PrepareImageStateDirs

func PrepareImageStateDirs(statePrefix, imageID string) (string, string, string, string)

PrepareImageStateDirs ensures that the required application directories exist

func PreparePostUpdateStateDir

func PreparePostUpdateStateDir(statePrefix string)

PreparePostUpdateStateDir ensures that the updated sensor is copied to the state directory if necessary

func PrepareReleaseStateDirs

func PrepareReleaseStateDirs(statePrefix, version string) (string, string)

PrepareReleaseStateDirs ensures that the required app release directories exist

func Remove

func Remove(artifactLocation string) error

Remove removes the artifacts generated during the current application execution

func SetAccess

func SetAccess(dst string, access *AccessInfo) error

SetAccess updates the access permissions on the destination

func Touch

func Touch(target string) error

Touch creates the target file or updates its timestamp

func UpdateFileTimes

func UpdateFileTimes(target string, atime, mtime syscall.Timespec) error

UpdateFileTimes updates the atime and mtime timestamps on the target file

func UpdateSymlinkTimes

func UpdateSymlinkTimes(target string, atime, mtime syscall.Timespec) error

UpdateSymlinkTimes updates the atime and mtime timestamps on the target symlink

Types

type AccessInfo

type AccessInfo struct {
	Flags     os.FileMode
	PermsOnly bool
	UID       int
	GID       int
}

AccessInfo provides the file object access properties

func NewAccessInfo

func NewAccessInfo() *AccessInfo

type SysStat

type SysStat struct {
	Ok    bool
	Uid   uint32
	Gid   uint32
	Atime syscall.Timespec
	Mtime syscall.Timespec
	Ctime syscall.Timespec
}

func SysStatInfo

func SysStatInfo(raw *syscall.Stat_t) SysStat

Jump to

Keyboard shortcuts

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