file: Index | Files

package file

import ""


Package Files

downloader.go file.go reader.go writer.go

func Basename Uses

func Basename(fp string) string

get filepath base name

func Close Uses

func Close(fd *os.File) error

close fd

func Create Uses

func Create(name string) (*os.File, error)

create one file

func Dir Uses

func Dir(fp string) string

get filepath dir name

func DirsUnder Uses

func DirsUnder(dirPath string) ([]string, error)

list dirs under dirPath

func Download Uses

func Download(toFile, url string) error

func EnsureDir Uses

func EnsureDir(fp string) error

mkdir dir if not exist

func EnsureDirRW Uses

func EnsureDirRW(dataDir string) error

ensure the datadir and make sure it's rw-able

func Ext Uses

func Ext(fp string) string

func FileMTime Uses

func FileMTime(fp string) (int64, error)

get file modified time

func FileSize Uses

func FileSize(fp string) (int64, error)

get file size as how many bytes

func FilesUnder Uses

func FilesUnder(dirPath string) ([]string, error)

list files under dirPath

func InsureDir Uses

func InsureDir(fp string) error

func IsExist Uses

func IsExist(fp string) bool

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

func IsFile Uses

func IsFile(fp string) bool

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

func MustOpenLogFile Uses

func MustOpenLogFile(fp string) *os.File

func ReadLine Uses

func ReadLine(r *bufio.Reader) ([]byte, error)

func RealPath Uses

func RealPath(fp string) (string, error)

get absolute filepath, based on built executable file

func Remove Uses

func Remove(name string) error

remove one file

func Rename Uses

func Rename(src string, target string) error

rename file name

func SearchFile Uses

func SearchFile(filename string, paths ...string) (fullPath string, err error)

Search a file in paths. this is often used in search config file in /etc ~/

func SelfDir Uses

func SelfDir() string

SelfDir gets compiled executable file directory

func SelfPath Uses

func SelfPath() string

SelfPath gets compiled executable file absolute path

func ToBytes Uses

func ToBytes(filePath string) ([]byte, error)

func ToInt64 Uses

func ToInt64(filePath string) (int64, error)

func ToString Uses

func ToString(filePath string) (string, error)

func ToTrimString Uses

func ToTrimString(filePath string) (string, error)

func ToUint64 Uses

func ToUint64(filePath string) (uint64, error)
func Unlink(fp string) error

delete file

func WriteBytes Uses

func WriteBytes(filePath string, b []byte) (int, error)

func WriteString Uses

func WriteString(filePath string, s string) (int, error)

Package file imports 12 packages (graph) and is imported by 436 packages. Updated 2016-09-08. Refresh now. Tools for package owners.