system

package
v0.0.0-...-27dc77f Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: BSD-1-Clause Imports: 7 Imported by: 0

Documentation

Overview

A group of functions about file system and native api

Index

Constants

View Source
const (
	FilePerm = 0644
	DirPerm  = 0755
)
View Source
const (
	LINUX   = "linux"
	WINDOWS = "windows"
	DARWIN  = "darwin"
	FREEBSD = "freebsd"
	SOLARIS = "solaris"
	ANDROID = "android"
	UNKNOWN = "unknown"
)

Variables

This section is empty.

Functions

func Dirname

func Dirname(path string) string

Return parent dir name of path

func EnvDef

func EnvDef(env, def string) string

func ExpandAbs

func ExpandAbs(path string) string

ExpandAbs expand path to absolute path

func ExpandHome

func ExpandHome(path string) string

ExpandHome expand ~ to user's home dir

func GetDefaultReleaseDir

func GetDefaultReleaseDir() []string

Get default folder names of released executables

func GoPath

func GoPath() (dir string, ok bool)

get GOPATH from env

func Home

func Home() string

Home return current user's Home dir

func HomeDir

func HomeDir() (path string, ok bool)

Get current user's home dir

func IsAndroid

func IsAndroid() bool

func IsDarwin

func IsDarwin() bool

func IsDir

func IsDir(fname string) bool

IsDir check whether or not given name is a dir

func IsDirOrNotExist

func IsDirOrNotExist(dir string) bool

IsDirOrNotExist check whether given is a directory or not exist

func IsExist

func IsExist(fname string) bool

IsExist check whether or not file/dir exist

func IsFile

func IsFile(fname string) bool

IsFile check whether or not file exist

func IsFileOrNotExist

func IsFileOrNotExist(fname string) bool

IsFileOrNotExist check whether given name is a file or not exist

func IsFreebsd

func IsFreebsd() bool

func IsLinux

func IsLinux() bool

func IsModifiedAfter

func IsModifiedAfter(fname string, fn func()) bool

IsModifiedAfter check whether or not file is modified by the function

func IsRelative

func IsRelative(path string) bool

IsRelative check whether a path is relative In these condition: path is empty, start with '[.~][/\]', '/', "[a-z]:\"

func IsRoot

func IsRoot(path string) bool

IsRoot check wether or not path is root of filesystem

func IsSolaris

func IsSolaris() bool
func IsSymlink(fname string) bool

IsSymlink check whether or not given name is a symlink

func IsWinRoot

func IsWinRoot(path string) bool

IsWinRoot check whether a path is windows absolute path with disk letter

func IsWindows

func IsWindows() bool

func LastDir

func LastDir(path string) (string, error)

LastDir return last dir of path, if path is dir, return itself else return path's contain dir name

func OS

func OS() string

func Platform

func Platform() string

func ProgramDir

func ProgramDir() (string, error)

ProgramDir return dir of program use os.Args[0]

func REGIST_SIGNAL_HANDLER

func REGIST_SIGNAL_HANDLER(handler func(os.Signal), signals ...os.Signal)

a simple signal notifier

func RemoveExt

func RemoveExt(path string) string

func ReplaceExt

func ReplaceExt(path, ext string) string

func ScanDir

func ScanDir(name string, callback func(path string, isdir bool))

Walk in dir and call user function func(path string, isdir bool)

func SearchFromSpecified

func SearchFromSpecified(name string, users ...string) (path string, ok bool)

Search file from user's dir if users, or search from GetDefaultReleaseDir Always used for find executable programs from specified folders of me!!!

func TruncSeek

func TruncSeek(fd *os.File)

TruncSeek truncate file size to 0 and seek current positon to 0

Types

type FStat

type FStat struct {
	Name   string
	Abs    string
	Base   string
	Parent string
	Seps   []string
	Stat   os.FileInfo
}

More complete file stat struct

func ListDir

func ListDir(name string) []FStat

Walk in dir and return all file's FStat

func NewFStat

func NewFStat(path string) (fstat *FStat, err error)

Parse path and return new FStat

Jump to

Keyboard shortcuts

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