Documentation ¶
Overview ¶
Package filemngt Created by RTT. Author: teocci@yandex.com on 2021-Aug-23
Package filemngt Created by Teocci. Author: teocci@yandex.com on 2021-Aug-26
Package filemngt Created by Teocci. Author: teocci@yandex.com on 2021-Aug-26
Index ¶
- Constants
- func CustomHomeDir() (string, error)
- func DirExists(p string) bool
- func DirExtractPathE(dir string) (string, error)
- func ErrCanNotExpandPath(p string, e string) error
- func ErrCanNotFindPWD(p, e string) error
- func ErrCanNotMakeDir(d, e string) error
- func ErrCanNotOpenFile(f, e string) error
- func ErrEmptyEnvironment() error
- func ErrEmptyOutputForHomeDir() error
- func ErrModeNotDefined(m string) error
- func ErrNotValidFile(f string) error
- func ErrPathExistIsNotDirectory(d string) error
- func ErrPathIsNotDirectory(d string) error
- func Expand(path string) string
- func ExpandByMode(path string, mode ExtractMode) (string, error)
- func ExpandByModeE(path string, mode ExtractMode) (string, error)
- func ExpandE(path string) (string, error)
- func FileExists(f string) bool
- func FileParentDirE(f string) (string, error)
- func FilePathE(f string) (string, error)
- func Hash(s string) (uint32, error)
- func IsDot(s string) bool
- func IsPathSeparator(s string) bool
- func IsPathValid(p string) bool
- func IsTilde(s string) bool
- func MakeDir(d string) error
- func MakeDirIfNotExist(d string) error
- func StartWithDot(s string) bool
- func StartWithPS(s string) bool
- func StartWithTilde(s string) bool
- func String(n int32) string
- func UserHomeDir() string
- func UserHomeDirE() (string, error)
- type ExtractMode
Constants ¶
const ( NativeEModeTag = "native" UserEModeTag = "user" CustomEModeTag = "custom" UndefinedEModeTag = "undefined" )
Variables ¶
This section is empty.
Functions ¶
func CustomHomeDir ¶
func DirExtractPathE ¶ added in v1.1.1
func ErrCanNotExpandPath ¶
func ErrCanNotFindPWD ¶ added in v1.1.1
func ErrCanNotMakeDir ¶
func ErrCanNotOpenFile ¶
func ErrEmptyEnvironment ¶
func ErrEmptyEnvironment() error
func ErrEmptyOutputForHomeDir ¶
func ErrEmptyOutputForHomeDir() error
func ErrModeNotDefined ¶
func ErrNotValidFile ¶
func ErrPathExistIsNotDirectory ¶ added in v1.1.1
func ErrPathIsNotDirectory ¶ added in v1.1.1
func Expand ¶
Expand expands a path to include the home directory as ExpandE Uses the NativeEMode as extraction mode. This function does not return errors.
func ExpandByMode ¶ added in v1.1.1
func ExpandByMode(path string, mode ExtractMode) (string, error)
ExpandByMode expands the path to include the home directory as ExpandByModeE. This function does not return errors.
func ExpandByModeE ¶ added in v1.1.1
func ExpandByModeE(path string, mode ExtractMode) (string, error)
ExpandByModeE expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is. This function also return errors if any.
func ExpandE ¶ added in v1.1.1
ExpandE expands the path to include the home directory as ExpandByModeE Uses the NativeEMode as extraction mode. This function also return errors if any.
func FileExists ¶ added in v1.1.1
FileExists checks if a file exists and is not a directory before we try using it to prevent further errors.
func FileParentDirE ¶ added in v1.1.1
FileParentDirE retrieve the file's parent directory. Uses the NativeEMode as extraction mode. This function also return errors if any.
func FilePathE ¶ added in v1.1.1
FilePathE retrieve the file's path. This function also return errors if any.
func IsPathSeparator ¶
func IsPathValid ¶ added in v1.1.1
func MakeDir ¶
MakeDir call os.Mkdir to create a new directory if already exits and check if the existing path is a directory This function also return errors if any.
func MakeDirIfNotExist ¶
MakeDirIfNotExist if the path does not exist call os.Mkdir to create a new directory This function also return errors if any.
func StartWithDot ¶ added in v1.1.1
func StartWithPS ¶ added in v1.1.1
func StartWithTilde ¶ added in v1.1.1
func UserHomeDir ¶ added in v1.1.1
func UserHomeDir() string
UserHomeDir returns the current user's home directory (if they have one). Uses the NativeEMode as extraction mode. This function does not return errors.
func UserHomeDirE ¶ added in v1.1.1
UserHomeDirE returns the current user's home directory (if they have one). There are three extraction modes: 1. NativeEMode calls os.UserHomeDir 2. UserEMode instantiate user.Current and gets the HomeDir value 3. CustomEMode calls CustomHomeDir This function also return errors if any.
Types ¶
type ExtractMode ¶
type ExtractMode int
const ( NativeEMode ExtractMode = iota UserEMode CustomEMode UndefinedEMode )