gfile

package
v0.0.0-...-3631402 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

文件管理.

Index

Constants

View Source
const (
	Separator = string(filepath.Separator)
)

文件分隔符

Variables

This section is empty.

Functions

func Basename

func Basename(path string) string

获取指定文件路径的文件名称

func Chmod

func Chmod(path string, mode os.FileMode) error

修改文件/目录权限

func Copy

func Copy(src string, dst string) error

文件复制

func Create

func Create(path string) error

给定文件的绝对路径创建文件

func Dir

func Dir(path string) string

获取指定文件路径的目录地址绝对路径

func Exists

func Exists(path string) bool

判断所给路径文件/文件夹是否存在

func Ext

func Ext(path string) string

获取指定文件路径的文件扩展名

func FormatSize

func FormatSize(raw float64) string

格式化文件大小

func GetBinContentByTwoOffsets

func GetBinContentByTwoOffsets(file *os.File, start int64, end int64) []byte

获得文件内容中两个offset之间的内容 [start, end)

func GetBinContents

func GetBinContents(path string) []byte

(二进制)读取文件内容

func GetContents

func GetContents(path string) string

(文本)读取文件内容

func GetNextCharOffset

func GetNextCharOffset(file *os.File, char string, start int64) int64

获得文件内容下一个指定字节的位置

func Glob

func Glob(pattern string) ([]string, error)

文件名正则匹配查找

func GoRootOfBuild

func GoRootOfBuild() string

编译时环境的GOROOT数值

func Home

func Home() (string, error)

获取用户主目录

func Info

func Info(path string) *os.FileInfo

获取文件或目录信息

func IsDir

func IsDir(path string) bool

判断所给路径是否为文件夹

func IsFile

func IsFile(path string) bool

判断所给路径是否为文件

func IsReadable

func IsReadable(path string) bool

文件是否可

func IsWritable

func IsWritable(path string) bool

文件是否可写

func MTime

func MTime(path string) int64

修改时间(秒)

func MTimeMillisecond

func MTimeMillisecond(path string) int64

修改时间(毫秒)

func MainPkgPath

func MainPkgPath() string

获取入口函数文件所在目录(main包文件目录), **仅对源码开发环境有效(即仅对生成该可执行文件的系统下有效)**

func Mkdir

func Mkdir(path string) error

给定文件的绝对路径创建文件

func Move

func Move(src string, dst string) error

文件移动/重命名

func Open

func Open(path string) (*os.File, error)

打开文件

func OpenWithFlag

func OpenWithFlag(path string, flag int) (*os.File, error)

打开文件

func PutBinContents

func PutBinContents(path string, content []byte) error

(二进制)写入文件内容

func PutBinContentsAppend

func PutBinContentsAppend(path string, content []byte) error

(二进制)追加内容到文件末尾

func PutContents

func PutContents(path string, content string) error

(文本)写入文件内容

func PutContentsAppend

func PutContentsAppend(path string, content string) error

(文本)追加内容到文件末尾

func ReadableSize

func ReadableSize(path string) string

格式化文件大小

func RealPath

func RealPath(path string) string

将所给定的路径转换为绝对路径 并判断文件路径是否存在,如果文件不存在,那么返回空字符串

func Remove

func Remove(path string) error

文件/目录删除

func Rename

func Rename(src string, dst string) error

文件移动/重命名

func ScanDir

func ScanDir(path string) []string

打开目录,并返回其下一级子目录名称列表,按照文件名称大小写进行排序

func SelfDir

func SelfDir() string

获取当前执行文件的目录绝对路径

func SelfPath

func SelfPath() string

获取当前执行文件的绝对路径

func Size

func Size(path string) int64

文件大小(bytes)

func TempDir

func TempDir() string

系统临时目录

func Truncate

func Truncate(path string, size int) error

Truncate

Types

This section is empty.

Jump to

Keyboard shortcuts

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