osutil

package
v0.0.0-...-4e6bda9 Latest Latest
Warning

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

Go to latest
Published: May 20, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirPerm  = 0755
	DefaultFilePerm = 0644
	DefaultExecPerm = 0755
)

Variables

This section is empty.

Functions

func Abs

func Abs(path string) string

func CopyFile

func CopyFile(oldFile, newFile string) error

CopyFile atomically copies oldFile to newFile preserving permissions and modification time.

func CopyFiles

func CopyFiles(srcDir, dstDir string, files []string) error

CopyFiles copies files from srcDir to dstDir as atomically as possible. Files are assumed to be relative names in slash notation. All other files in dstDir are removed.

func FilesExist

func FilesExist(dir string, files []string) bool

FilesExist returns true if all files exist in dir. Files are assumed to be relative names in slash notation.

func HandleInterrupts

func HandleInterrupts(shutdown chan struct{})

HandleInterrupts closes shutdown chan on first SIGINT (expecting that the program will gracefully shutdown and exit) and terminates the process on third SIGINT.

func IsExist

func IsExist(name string) bool

IsExist returns true if the file name exists.

func LinkFiles

func LinkFiles(srcDir, dstDir string, files []string) error

LinkFiles creates hard links for files from dstDir to srcDir. Files are assumed to be relative names in slash notation. All other files in dstDir are removed.

func ListDir

func ListDir(dir string) ([]string, error)

Return all files in a directory.

func LongPipe

func LongPipe() (io.ReadCloser, io.WriteCloser, error)

func MkdirAll

func MkdirAll(dir string) error

func ProcessTempDir

func ProcessTempDir(where string) (string, error)

ProcessTempDir creates a new temp dir in where and returns its path and an unique index. It also cleans up old, unused temp dirs after dead processes.

func RunCmd

func RunCmd(timeout time.Duration, dir, bin string, args ...string) ([]byte, error)

RunCmd runs "bin args..." in dir with timeout and returns its output.

func RunCmdEnv

func RunCmdEnv(timeout time.Duration, env []string, dir, bin string, args ...string) ([]byte, error)

RunCmdEnv is the same as RunCmd but also appends env.

func UmountAll

func UmountAll(dir string)

UmountAll recurusively unmounts all mounts in dir.

func WriteExecFile

func WriteExecFile(filename string, data []byte) error

func WriteFile

func WriteFile(filename string, data []byte) error

func WriteTempFile

func WriteTempFile(data []byte) (string, error)

WriteTempFile writes data to a temp file and returns its name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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