filetool

package
Version: v0.0.0-...-470e8f5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2014 License: BSD-3-Clause Imports: 7 Imported by: 36

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Basename

func Basename(file string) string

get filepath base name

func Dir

func Dir(file string) string

get filepath dir name

func DirsUnder

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

list dirs under dirPath

func Ext

func Ext(file string) string

func FileMTime

func FileMTime(file string) (int64, error)

get file modified time

func FileSize

func FileSize(file string) (int64, error)

get file size as how many bytes

func FileToInt64

func FileToInt64(file string) (int64, error)

func FileToUint64

func FileToUint64(file string) (uint64, error)

func FilesUnder

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

list files under dirPath

func InsureDir

func InsureDir(path string) error

func IsExist

func IsExist(path string) bool

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

func IsFile

func IsFile(filePath string) bool

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

func ReadFileToBytes

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

ReadFileToBytes reads data type '[]byte' from file by given path. It returns error when fail to finish operation.

func ReadFileToString

func ReadFileToString(filePath string) (string, error)

ReadFileToString reads data type 'string' from file by given path. It returns error when fail to finish operation.

func ReadFileToStringNoLn

func ReadFileToStringNoLn(filePath string) (string, error)

func RealPath

func RealPath(file string) (string, error)

get absolute filepath, based on built executable file

func Rename

func Rename(file string, to string) error

rename file name

func SearchFile

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

func SelfDir() string

SelfDir gets compiled executable file directory

func SelfPath

func SelfPath() string

SelfPath gets compiled executable file absolute path

func Unlink(file string) error

delete file

func WriteBytesToFile

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

WriteBytesToFile saves content type '[]byte' to file by given path. It returns error when fail to finish operation.

func WriteStringToFile

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

WriteStringFile saves content type 'string' to file by given path. It returns error when fail to finish operation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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