system

package
v1.7.0-rc0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OsWindows = "windows"
	OsMac     = "darwin"
	OsLinux   = "linux"

	Arch64 = "amd64"
	Arch32 = "386"
)

Variables

This section is empty.

Functions

func CleanUpFileOperation

func CleanUpFileOperation(file *os.File, returnError *error)

func DeleteProgram

func DeleteProgram(deleteProgramPath string) error

DeleteProgram immediately deletes the binary or MacOS application bundle at deleteProgramPath, unless the operating system is Windows; in that case the file at deleteProgramPath will be deleted after 3 seconds.

func FileExists

func FileExists(filePath string) bool

func FindPaths added in v1.3.2

func FindPaths() (err error, evalErr error)

func FolderExists

func FolderExists(folderPath string) bool

func GetBinaryPath

func GetBinaryPath() string

GetBinaryPath returns the path where the binary of the calling program lies.

func GetOSArch

func GetOSArch() string

Returns "amd64" if the underlying OS is 64 bit. Returns "386" otherwise. This is compliant with the GOARCH naming scheme. Do not confuse the result of this function with runtime.GOARCH, which describes the architecture this binary was built for instead.

func GetPidCreateTime

func GetPidCreateTime(pid int) (time int64, err error)

func GetProcessCreateTime

func GetProcessCreateTime(proc *os.Process) (time int64, err error)

Reports the time at which the given process launched in some format, with at least millisecond precision.

func GetProgramPath

func GetProgramPath() string

GetProgramPath returns the path where the calling program lies. This will be identical to the result of GetBinaryPath() unless the OS is MacOS, where GetProgramPath() will return the path of the program's application bundle folder.

func Is64BitOS

func Is64BitOS() bool

func IsDir

func IsDir(path string) bool

func IsEmpty

func IsEmpty(filePath string) bool

func IsPermission added in v1.4.0

func IsPermission(err error) bool

IsPermission returns true if err or any of its nested errors return true for os.IsPermission().

func IsPidRunning

func IsPidRunning(pid int) bool

func IsProcessSignatureRunning

func IsProcessSignatureRunning(procSig *ProcessSignature) bool

func MatchesPlatform

func MatchesPlatform(platform string, os string, arch string) bool

func MustCopyAll

func MustCopyAll(src, dst string)

Copy the file or folder at src to dst. If dst is taken by an existing file or folder, it will be removed beforehand.

func MustCopyFile

func MustCopyFile(from, to string)

func MustGetAbsolutePath

func MustGetAbsolutePath(filePath string) string

func MustMakeDir

func MustMakeDir(dirPath string)

func MustMakeTempDirectory

func MustMakeTempDirectory(forFolderAtPath string) string

func MustMoveAll

func MustMoveAll(src, dst string)

Move the file or folder at src to dst. If dst is taken by an existing file or folder, it will be removed beforehand.

func MustMoveFiles

func MustMoveFiles(fromDirectory, toDirectory string)

Recursively moves all content of fromDirectory into toDirectory, overwriting existing files when encountered.

func MustPutFile

func MustPutFile(localFilePath string, bytes []byte)

func MustReadFile

func MustReadFile(filePath string) []byte

func MustRecursivelyRemoveEmptyFolders

func MustRecursivelyRemoveEmptyFolders(folder string) bool

func MustRemoveFile

func MustRemoveFile(filePath string)

func ShowLocalFileInFileManager

func ShowLocalFileInFileManager(path string) error

func TryRemove

func TryRemove(filePath string)

func TryRemoveDirectory

func TryRemoveDirectory(path string)

func TryRemoveEmpty

func TryRemoveEmpty(filePath string)

func UndeployProgram

func UndeployProgram(undeployProgramPath string) (string, error)

UndeployProgram renames the file at undeployProgramPath on operating systems where running binaries cannot be deleted (i.e. Windows) and returns the path to the renamed file. Otherwise, the provided string is returned with a non-nil error.

Types

type FileSystemError

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

func NewFileSystemError added in v1.4.0

func NewFileSystemError(message string, cause error) *FileSystemError

func (*FileSystemError) Error

func (fse *FileSystemError) Error() string

func (*FileSystemError) Unwrap added in v1.4.0

func (fse *FileSystemError) Unwrap() error

type ProcessSignature

type ProcessSignature struct {
	Pid        int   `json:"Pid"`
	CreateTime int64 `json:"CreateTime"`
}

func GetCurrentProcessSignature

func GetCurrentProcessSignature() *ProcessSignature

func GetPidProcessSignature

func GetPidProcessSignature(pid int) *ProcessSignature

func StartProcess added in v1.3.3

func StartProcess(binaryPath string, workingDirectoryPath string, args []string, extraEnvironmentVariables map[string]*string, passStreams bool) (*exec.Cmd, *ProcessSignature, error)

Jump to

Keyboard shortcuts

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