gfile

package
v0.0.0-...-3e416e1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 6 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(p string) string

Abs is similar to Abs in the std library "path/filepath", but firstly convert "~"" and "$HOME" to the home directory.

Return the origin path if there is an error.

func BaseName

func BaseName(file string) string

BaseName returns file name end of the path with extension.

func Bytes

func Bytes(file string) (d []byte)

Bytes returns the []byte contents of file, if read fail, returns nil.

func Copy

func Copy(srcFile, dstFile string, mkdir bool) error

Copy source path file to destination file path, when mkdir is true and destination path not exists, the destination dir will be created

func Exists

func Exists(path string) bool

Exists checks whether a file or directory exists. It returns false when the file or directory does not exists.

func FileMTime

func FileMTime(file string) (time.Time, error)

FileMTime get file modified time

func FileName

func FileName(file string) string

FileName returns file name end of the path without extension.

func FileSize

func FileSize(file string) (int64, error)

FileSize get file size as how many bytes

func HomeDir

func HomeDir() string

HomeDir returns the home directory.

Return "" if the home directory is empty.

func IsDir

func IsDir(file string) bool

IsDir checks whether the path is a directory, it returns false when it's not a directory or does not exists.

func IsEmptyDir

func IsEmptyDir(path string) bool

IsEmptyDir returns true if the directory contains nothing, otherwise returns false

func IsFile

func IsFile(file string) bool

IsFile checks whether the path is a file, it returns false when it's a directory or does not exists.

func IsLink(path string) bool

IsLink returns true if path is a Symlink

func ReadAll

func ReadAll(file string) string

ReadAll returns string contents of file, if read fail, returns empty.

func ResolveLink(path string) (string, error)

ResolveLink resolves the link if it is a Link or return the original path

func Write

func Write(file string, data []byte, append bool) (err error)

Write writes []byte to file.

func WriteString

func WriteString(file string, data string, append bool) (err error)

WriteString writes string to file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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