osutil

package
v0.0.0-...-c39e8e5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: AGPL-3.0 Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arg0

func Arg0() string

Arg0 returns the first arg, often represents the path of the binary.

func Arg0Base

func Arg0Base() string

Arg0Base returns the base name of the first arg, which often represents the name of the binary.

func CheckPrivateFile

func CheckPrivateFile(f string) error

CheckPrivateFile checks if the file is of the right permission bits.

func CmdAddEnv

func CmdAddEnv(cmd *exec.Cmd, k, v string) bool

CmdAddEnv adds an environment variable to cmd and returns true. If v is an empty string, nothing is added, and it returns false.

func CmdCopyEnv

func CmdCopyEnv(cmd *exec.Cmd, k string) bool

CmdCopyEnv copies the value of environment variable k to cmd. If the value is empty, returns false; otherwise returns true.

func Exist

func Exist(path string) (bool, error)

Exist checks if a path exists.

func IsDir

func IsDir(path string) (bool, error)

IsDir checks if a directory exists.

func IsRegular

func IsRegular(path string) (bool, error)

IsRegular checks if a path is a regular file.

func IsSock

func IsSock(path string) (bool, error)

IsSock checks if a file a unix domain socket.

func ReadOptionalTokenFile

func ReadOptionalTokenFile(f string) (string, bool, error)

ReadOptionalTokenFile reads an optional token file.

func ReadPrivateFile

func ReadPrivateFile(f string) ([]byte, error)

ReadPrivateFile reads the confent of a file. The file must be mode 0600.

func ReadTokenFile

func ReadTokenFile(f string) (string, error)

ReadTokenFile reads a token string from a file.

Types

type Home

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

Home is a directory for referecing files under a directory.

func NewHome

func NewHome(dir string) (*Home, error)

NewHome creates a new home directory.

func (*Home) Dir

func (h *Home) Dir() string

Dir returns the base directory, it is always in its absolute form.

func (*Home) Etc

func (h *Home) Etc(p string) string

Etc returns a file path under dir "etc/"

func (*Home) FilePath

func (h *Home) FilePath(p string) string

FilePath returns a sub path under the home directory. p is in URL path, but the returned value is in filepath format, in OS's filepath separators.

func (*Home) Lib

func (h *Home) Lib(p string) string

Lib returns a file path under dir "lib/"

func (*Home) Tmp

func (h *Home) Tmp(p string) string

Tmp returns a file path under dir "tmp/"

func (*Home) Var

func (h *Home) Var(p string) string

Var returns a file path under dir "var/"

Jump to

Keyboard shortcuts

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