files

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseNoExt

func BaseNoExt(filename string) (outFilename string)

BaseNoExt: get only the name without ext.

func CheckOutsideDir

func CheckOutsideDir(baseFilename, newFilename string) bool

CheckOutsideDir: Check if 'filenameNew' is in the same directory as 'filenameOrig'. returns 'false' if the 'root' directory is the same.

func CheckOutsideRoot

func CheckOutsideRoot(rootDir, filePath string) (count int)

CheckOutsideRoot: Check if 'filePath' is outside the current scope of the 'rootDir' (must be a DIRECTORY). count = 0 means 'filePath' is at the same level than 'rootDir'. count > 0 means 'filePath' is in a sub-directory of 'rootDir' and the value

indicate how many sub-directories.

count < 0 means how many parent directories relative to base directory.

func DirKeepSame

func DirKeepSame(f1, f2 string) (same, diff []string)

DirKeepSame: returns 'same' which corresponds to the equal parts of the two files and 'diff' which corresponds to the change between the two, the 'f1' argument must be the shortest path.

func ExtEnsure

func ExtEnsure(filename, ext string, option ...EEOptions) string

ExtEnsure: Ensuring that the filename has the desired extension. 'option' correspond to 'EEOptions' declaration above.

func ExtFileMatch

func ExtFileMatch(name string, patterns []string) bool

FileMatch: If a pattern contained in "patterns" match, true is returned

func FileInfos

func FileInfos(filename string) error

FileInfos: As remind for available file information.

func GenFileName

func GenFileName() string

GenFileName: Generate a randomized file name

func GetAbsRealPath

func GetAbsRealPath(optionDir string, devMode bool, realUser ...*user.User) (absoluteRealPath, optFilename string)

Retrieve current realpath and options filename. Options/Config path depend on devMode value, true means current directory, false means current/real user directory '~/.config/Creat/appName' 'realUser' if provided will set the current user (used for root access).

func GetCurrentDir

func GetCurrentDir() (dir string, err error)

GetCurrentDir: Get current directory

func GetSimpleFileType

func GetSimpleFileType(filename string) string

GetSimpleFileType: scan first bytes to detect type of file. This is a basic version for kick usage.

func IsDirEmpty

func IsDirEmpty(name string) (empty bool, err error)

IsDirEmpty:

func IsDirOrSymlinkDir

func IsDirOrSymlinkDir(slRoot string, slStat os.FileInfo) (slIsDir bool)

IsDirOrSymlinkDir: File is a directory or a symlinked directory ? Need: os.FileInfo - > os.Lstat

func RemovePathBefore

func RemovePathBefore(path []string, at string, after ...bool) []string

removePathBefore: remove directories before or after the chosen name

func SizeToBytes

func SizeToBytes(size uint32) []byte

sizeToBytes: convert uint32 size to bytes representation (32bits) "000001f1"

func SplitPath

func SplitPath(path string) (outSlice []string)

splitPath: make a slice from a string path

func TempFileName

func TempFileName(prefix, suffix string) string

TempFileName generates a temporary filename for use in testing or whatever

func TempMake

func TempMake(prefix string) string

TempMake: Make temporary directory

func TempRemove

func TempRemove(fName string) (err error)

TempRemove: Remove directory recursively

func TruncatePath

func TruncatePath(fullpath string, count ...int) (reduced string)

ReducePath: Reduce path length by preserving count element from the end

Types

type EEOptions

type EEOptions int

EEOptions: options for 'ExtEnsure' function.

const (
	EE_DEFAULT           EEOptions = 1 << 0
	EE_REM_ALL_AFTER_DOT EEOptions = 1 << 1 // Remove all after the first dot
	EE_PRESERVE_FILENAME EEOptions = 1 << 2 // Preserve full filename, just adding extension
)

Jump to

Keyboard shortcuts

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