gfile

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Separator 系统路径分割符
	Separator = string(filepath.Separator)
)

Variables

This section is empty.

Functions

func Basename

func Basename(path string) string

Basename 获取最内层文件夹或文件名称,如果不存在,返回"."

func Chmod

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

Chmod 修改路径权限

func Copy

func Copy(src string, dst string) error

Copy 复制文件或文件夹

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir 复制文件夹

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile 复制文件

func Create

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

Create 创建文件

func Dir

func Dir(path string) string

Dir 获取文件所在文件夹,如果path="",则返回"."

func DirNames

func DirNames(path string) ([]string, error)

DirNames 获取子文件夹列表

func Exists

func Exists(path string) bool

Exists 检查文件是否存在

func Ext

func Ext(path string) string

Ext 获取文件后掇,返回文件后缀中包含"."

func GetBinContents

func GetBinContents(path string) []byte

GetBinContents 获取文件内容,文件不存在时返回nil

func GetBinContentsByTwoOffsets

func GetBinContentsByTwoOffsets(reader io.ReaderAt, start int64, end int64) []byte

GetBinContentsByTwoOffsets 从reader中获取从位置start到end之间的二进制数据

func GetBinContentsByTwoOffsetsByPath

func GetBinContentsByTwoOffsetsByPath(path string, start int64, end int64) []byte

GetBinContentsByTwoOffsetsByPath 从文件path中,获取从位置start到end之间的二进制数据

func GetBinContentsTilChar

func GetBinContentsTilChar(reader io.ReaderAt, char byte, start int64) ([]byte, int64)

GetBinContentsTilChar 在reader中,获取从start到字符char之间二进制数据,包含char在内

func GetBinContentsTilCharByPath

func GetBinContentsTilCharByPath(path string, char byte, start int64) ([]byte, int64)

GetBinContentsTilCharByPath 在文件path中,获取从start位置到字符char之间的二进制数据,包含char在内

func GetContents

func GetContents(path string) string

GetContents 获取文件内容,返回字符串,文件不存在时返回空字符串

func GetNextCharOffset

func GetNextCharOffset(reader io.ReaderAt, char byte, start int64) int64

GetNextCharOffset 从start之后查找char字符,如果找到返回找到位置,否则返回-1

func GetNextCharOffsetByPath

func GetNextCharOffsetByPath(path string, char byte, start int64) int64

GetNextCharOffsetByPath 在文件path中从start之后查找字符char,找到则返回所在位置,否则返回-1

func Glob

func Glob(pattern string, onlyNames ...bool) ([]string, error)

Glob 按指定规则查找获取文件或文件夹

func Home

func Home() (string, error)

Home 获取用户根目录

func Info

func Info(path string) (os.FileInfo, error)

Info 获取路径信息,Stat别名

func IsDir

func IsDir(path string) bool

IsDir 检查路径是否是文件夹

func IsFile

func IsFile(path string) bool

IsFile 检查路径是否是文件

func IsReadable

func IsReadable(path string) bool

IsReadable 检查路径是否可读

func IsWritable

func IsWritable(path string) bool

IsWritable 检查路径是否可写

func Join

func Join(subPath ...string) string

Join 以路径分隔符连接路径并返回

func MainPkgPath

func MainPkgPath() string

MainPkgPath 获取主项目目录

func Mkdir

func Mkdir(path string) error

Mkdir 创建文件夹

func Move

func Move(src string, dst string) error

Move 移动文件或文件夹

func Open

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

Open opens file/directory readonly. 以只读方式打开文件或文件夹

func OpenFile

func OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)

OpenFile 以指定文件打开文件或文件夹

func OpenWithFlag

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

OpenWithFlag 以默认权限打开文件或文件夹

func OpenWithFlagPerm

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

OpenWithFlagPerm 以指定权限打开文件或文件夹

func PutBinContents

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

PutBinContents 写入二进制数据到文件,文件不存在时创建

func PutBinContentsAppend

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

PutBinContentsAppend 追回二进制数据到文件,文件不存在时创建

func PutContents

func PutContents(path string, content string) error

PutContents 将字符串写入文件

func PutContentsAppend

func PutContentsAppend(path string, content string) error

PutContentsAppend 追加字符串到文件,文件不存在时创建文件

func Pwd

func Pwd() string

Pwd 返回当前工作目录

func RealPath

func RealPath(path string) string

RealPath 获取路径的绝对路径,如果路径不存在返回空字符串

func Remove

func Remove(path string) error

Remove 删除文件或文件夹

func Rename

func Rename(src string, dst string) error

Rename 重命名文件或文件夹

func ScanDir

func ScanDir(path string, pattern string, recursive ...bool) ([]string, error)

ScanDir 扫描路径中的文件夹,包含子文件夹中的所有文件,返回文件列表

func SelfDir

func SelfDir() string

SelfDir 获取当前程序所在路径

func SelfName

func SelfName() string

SelfName 获取当前程序名称

func SelfPath

func SelfPath() string

SelfPath 获取当前程序所在路径

func Stat

func Stat(path string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError. 获取路径信息

func TempDir

func TempDir() string

TempDir 临时目录

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