utils

package
v0.0.0-...-dddda54 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: GPL-3.0 Imports: 22 Imported by: 68

Documentation

Index

Constants

View Source
const (
	SCHEME_FILE  = "file://"
	SCHEME_FTP   = "ftp://"
	SCHEME_HTTP  = "http://"
	SCHEME_HTTPS = "https://"
	SCHEME_SMB   = "smb://"
)

Variables

View Source
var (
	DefaultHomeConfigPrefix   = os.Getenv("HOME") + "/.config/deepin/"
	DefaultSystemConfigPrefix = "/var/cache/deepin/"
	DefaultConfigExt          = ".json"
)
View Source
var DefaultCachePrefix = os.Getenv("HOME") + "/.cache/deepin"

Functions

func CheckAndNewGSettings

func CheckAndNewGSettings(schema string) (*gio.Settings, error)

func CopyDir

func CopyDir(src, dest string) error

func CopyFile

func CopyFile(src, dest string) (err error)

func CreateFile

func CreateFile(filename string) error

func DecodeURI

func DecodeURI(uri string) (content string)

func EncodeURI

func EncodeURI(content, scheme string) (uri string)

func EnsureDirExist

func EnsureDirExist(path string) error

func EnsureDirExistWithPerm

func EnsureDirExistWithPerm(path string, perm os.FileMode) error

func ExecAndWait

func ExecAndWait(timeout int, name string, arg ...string) (stdout, stderr string, err error)

func GenUuid

func GenUuid() string

func GenerateCacheFilePath

func GenerateCacheFilePath(keyword string) (dstfile string)

func GenerateCacheFilePathWithPrefix

func GenerateCacheFilePathWithPrefix(prefix, keyword string) (dstfile string)

func GetCacheDir

func GetCacheDir() string

func GetConfigDir

func GetConfigDir() string

func GetFilesInDir

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

func GetHomeDir

func GetHomeDir() string

func GetURIContent

func GetURIContent(uri string) (content string)

func GetURIScheme

func GetURIScheme(uri string) (scheme string)

func GetUserName

func GetUserName() string

func IsDir

func IsDir(path string) bool

func IsElementEqual

func IsElementEqual(e1, e2 interface{}) bool

func IsElementInList

func IsElementInList(e interface{}, list interface{}) bool

func IsEnvExists

func IsEnvExists(envName string) (ok bool)

func IsFileExist

func IsFileExist(path string) bool

func IsGSchemaExist

func IsGSchemaExist(schema string) bool

func IsInterfaceNil

func IsInterfaceNil(v interface{}) bool
func IsSymlink(path string) bool

func IsURI

func IsURI(s string) (ok bool)

func MoveDir

func MoveDir(src, dest string) error

func MoveFile

func MoveFile(src, dest string) error

func NewKeyFileFromFile

func NewKeyFileFromFile(file string) (*glib.KeyFile, error)

func PathToURI

func PathToURI(filepath, scheme string) string

func RandString

func RandString(n int) string

func ReadKeyFromKeyFile

func ReadKeyFromKeyFile(filename, group, key string, t interface{}) (interface{}, bool)

func SumFileMd5

func SumFileMd5(filename string) (string, bool)

func SumStrMd5

func SumStrMd5(str string) (string, bool)

func SymlinkFile

func SymlinkFile(src, dest string) error

func SyncWriteFile

func SyncWriteFile(filename string, data []byte, perm os.FileMode) error

同步写入文件

func URIToPath

func URIToPath(uri string) string

func UnsetEnv

func UnsetEnv(envName string) (err error)

func WriteKeyToKeyFile

func WriteKeyToKeyFile(filename, group, key string, value interface{}) bool

func WriteStringToFile

func WriteStringToFile(filename, content string) error

func WriteStringToKeyFile

func WriteStringToKeyFile(filename, content string) bool

TODO: Abandoned it Do't use this interface.

Types

type Config

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

func (*Config) GetConfigFile

func (c *Config) GetConfigFile() string

func (*Config) GetFileContentToSave

func (c *Config) GetFileContentToSave(v interface{}) (fileContent []byte, err error)

func (*Config) IsConfigFileExists

func (c *Config) IsConfigFileExists() bool

func (*Config) Load

func (c *Config) Load(v interface{}) (err error)

func (*Config) Lock

func (c *Config) Lock()

func (*Config) RemoveConfigFile

func (c *Config) RemoveConfigFile() error

func (*Config) Save

func (c *Config) Save(v interface{}) (err error)

func (*Config) SetConfigFile

func (c *Config) SetConfigFile(file string)

func (*Config) SetConfigName

func (c *Config) SetConfigName(name string)

func (*Config) SetSystemConfigName

func (c *Config) SetSystemConfigName(name string)

func (*Config) Unlock

func (c *Config) Unlock()

type FilesystemInfo

type FilesystemInfo struct {
	TotalSize uint64 // byte
	FreeSize  uint64
	AvailSize uint64
	UsedSize  uint64
}

func QueryFilesytemInfo

func QueryFilesytemInfo(path string) (*FilesystemInfo, error)

type WatchProxy

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

func NewWatchProxy

func NewWatchProxy() *WatchProxy

func (*WatchProxy) EndWatch

func (w *WatchProxy) EndWatch()

func (*WatchProxy) ResetFileListWatch

func (w *WatchProxy) ResetFileListWatch()

func (*WatchProxy) SetErrorHandler

func (w *WatchProxy) SetErrorHandler(f func(error))

func (*WatchProxy) SetEventHandler

func (w *WatchProxy) SetEventHandler(f func(fsnotify.Event))

func (*WatchProxy) SetFileList

func (w *WatchProxy) SetFileList(fileList []string)

func (*WatchProxy) StartWatch

func (w *WatchProxy) StartWatch()

Jump to

Keyboard shortcuts

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