os

package
v0.0.133 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultPermissionFile      os.FileMode = 0644
	DefaultPermissionDirectory os.FileMode = 0755
)

Variables

View Source
var ShutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM}

Functions

func Append added in v0.0.114

func Append(dst string, src string) error

Append creates or appends the dst file or dir, filled with content from src file. If the dst file already exists, it is truncated. If the dst file does not exist, it is created with mode 0666 (before umask). If the dst dir does not exist, it is created with mode 0755 (before umask). parent dirs will not be created, otherwise, use AppendAll instead.

func AppendAll added in v0.0.113

func AppendAll(dst string, src string) error

AppendAll creates or appends the dst file or dir, filled with content from src file. If the dst file already exists, it is truncated. If the dst file does not exist, it is created with mode 0666 (before umask). If the dst dir does not exist, it is created with mode 0755 (before umask).

func ChtimesNow added in v0.0.23

func ChtimesNow(name string) error

Chtimes changes the access and modification times of the named file with Now, similar to the Unix utime() or utimes() functions.

The underlying filesystem may truncate or round the values to a less precise time unit. If there is an error, it will be of type *PathError.

func Copy added in v0.0.114

func Copy(dst string, src string) error

Copy creates or truncates the dst file or dir, filled with content from src file. If the dst file already exists, it is truncated. If the dst file does not exist, it is created with mode 0666 (before umask). If the dst dir does not exist, it is created with mode 0755 (before umask). parent dirs will not be created, otherwise, use CopyAll instead.

func CopyAll added in v0.0.113

func CopyAll(dst string, src string) error

CopyAll creates or truncates the dst file or dir, filled with content from src file. If the dst file already exists, it is truncated. If the dst file does not exist, it is created with mode 0666 (before umask). If the dst dir does not exist, it is created with mode 0755 (before umask).

func CopyFile added in v0.0.104

func CopyFile(dst string, src string, flag int, perm os.FileMode) error

CopyFile is the generalized open call; most users will use Copy or Append instead. It opens the named file or directory with specified flag (O_RDONLY etc.). CopyFile copies from src to dst. parent dirs will not be created, otherwise, use CopyFileAll instead.

func CopyFileAll added in v0.0.113

func CopyFileAll(dst string, src string, flag int, dirperm, fileperm os.FileMode) error

CopyFileAll is the generalized open call; most users will use CopyAll or AppendAll instead. It opens the named file or directory with specified flag (O_RDONLY etc.). If the dst file does not exist, and the O_CREATE flag is passed, it is created with mode fileperm (before umask). If the dst directory does not exist,, it is created with mode dirperm (before umask). If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.

func CreateAll added in v0.0.23

func CreateAll(path string) (*os.File, error)

CreateAll creates or truncates the named file or dir. If the file already exists, it is truncated. If the file does not exist, it is created with mode 0666 (before umask). If the dir does not exist, it is created with mode 0755 (before umask).

func CreateAllIfNotExist added in v0.0.23

func CreateAllIfNotExist(path string) (*os.File, error)

CreateAllIfNotExist creates the named file or dir. If the file does not exist, it is created with mode 0666 (before umask). If the dir does not exist, it is created with mode 0755 (before umask). If path is already a directory, CreateAllIfNotExist does nothing and returns nil.

func GetAbsBinDir

func GetAbsBinDir() (dir string, err error)

func Make added in v0.0.115

func Make(name string) error

MakeAll creates a directory named path and returns nil, or else returns an error. If the dir does not exist, it is created with mode 0755 (before umask).

func MakeAll added in v0.0.115

func MakeAll(name string) error

MakeAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. If the dir does not exist, it is created with mode 0755 (before umask).

func OpenAll added in v0.0.113

func OpenAll(path string) (*os.File, error)

OpenAll opens the named file or dir for reading. If successful, methods on the returned file or dir can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func OpenFileAll added in v0.0.113

func OpenFileAll(path string, flag int, dirperm, fileperm os.FileMode) (*os.File, error)

OpenFileAll is the generalized open call; most users will use OpenAll or CreateAll instead. It opens the named file or directory with specified flag (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag is passed, it is created with mode fileperm (before umask). If the directory does not exist,, it is created with mode dirperm (before umask). If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.

func PathExists

func PathExists(path string) (bool, error)

func SameFile added in v0.0.104

func SameFile(fi1, fi2 string) bool

SameFile reports whether fi1 and fi2 describe the same file. Overload os.SameFile by file path

func TouchAll added in v0.0.23

func TouchAll(path string) (*os.File, error)

TouchAll creates the named file or dir. If the file already exists, it is touched to now. If the file does not exist, it is created with mode 0666 (before umask). If the dir does not exist, it is created with mode 0755 (before umask).

Types

type FileInfos added in v0.0.115

type FileInfos []os.FileInfo

func (FileInfos) Len added in v0.0.115

func (s FileInfos) Len() int

func (FileInfos) Less added in v0.0.115

func (s FileInfos) Less(i, j int) bool

func (FileInfos) Swap added in v0.0.115

func (s FileInfos) Swap(i, j int)

type WalkFileInfo added in v0.0.115

type WalkFileInfo struct {
	Path     string
	FileInfo os.FileInfo
}

WalkFileInfo is a wrapper for sort of filepath.WalkFunc

type WalkFileInfos added in v0.0.115

type WalkFileInfos []WalkFileInfo

func (WalkFileInfos) Len added in v0.0.115

func (w WalkFileInfos) Len() int

func (WalkFileInfos) Less added in v0.0.115

func (w WalkFileInfos) Less(i, j int) bool

func (WalkFileInfos) Swap added in v0.0.115

func (w WalkFileInfos) Swap(i, j int)

Jump to

Keyboard shortcuts

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