gfile

package
v1.12.22 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

file 文件相关的一些辅助函数

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Basename

func Basename(path string) string

Basename basename()

func CheckPathExist

func CheckPathExist(path string) bool

CheckPathExist check file or path exist

func Chmod

func Chmod(filename string, mode os.FileMode) bool

Chmod chmod()

func Chown

func Chown(name string, info os.FileInfo) error

Chown 清空文件并保持文件权限不变,并非linux chown操作 Empty the file and keep the file permissions unchanged not the linux chown operation

func CopyFile

func CopyFile(distName, srcName string) (w int64, err error)

CopyFile 复制文件到另一个文件

func Fclose

func Fclose(handle *os.File) error

Fclose fclose()

func Fgetcsv

func Fgetcsv(handle *os.File, delimiter rune, size ...int64) ([][]string, error)

Fgetcsv fgetcsv() 默认当文件大小大于10MB逐行读取内容,否则一次性读取内容 第三个参数可以指定逐行读取的最大文件大小,单位字节 1MB = 1 << 20

func FileChown

func FileChown(filename string, uid, gid int) bool

Chown chown()

func FileExists

func FileExists(filename string) bool

FileExists file_exists()

func FileGetContents

func FileGetContents(filename string) (string, error)

FileGetContents file_get_contents()

func FilePutContents

func FilePutContents(filename string, data string, mode os.FileMode) error

FilePutContents file_put_contents()

func FileSize

func FileSize(filename string) (int64, error)

FileSize filesize()

func Filebase

func Filebase(file string) string

Filebase 获取文件的名称不带后缀 get the name of the file without a suffix

func Fileline

func Fileline(file string, line int) string

Fileline 获取文件名:行数

func Filemtime

func Filemtime(filename string) (int64, error)

Filemtime filemtime()

func Getcwd

func Getcwd() (string, error)

Getcwd getcwd()

func Glob

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

Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in Match. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/').

Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.

func Gunzip

func Gunzip(in []byte) ([]byte, error)

Gunzip decompress data user gunzip

func Gzip

func Gzip(in []byte) ([]byte, error)

Gzip compress data use gzip

func IsDir

func IsDir(filename string) (bool, error)

IsDir is_dir()

func IsFile

func IsFile(filename string) bool

IsFile is_file()

func IsReadable

func IsReadable(filename string) bool

IsReadable is_readable()

func IsWriteable

func IsWriteable(filename string) bool

IsWriteable is_writeable()

func LoadGobData

func LoadGobData(data interface{}, fileName string)

LoadGobData 将gob写入的内容,载入到data中

func Mkdir

func Mkdir(filename string, mode os.FileMode) error

Mkdir mkdir()

func Pathinfo

func Pathinfo(path string, options int) map[string]string

Pathinfo pathinfo() -1: all; 1: dirname; 2: basename; 4: extension; 8: filename Usage: Pathinfo("/home/go/path/src/php2go/php2go.go", 1|2|4|8)

func Realpath

func Realpath(path string) (string, error)

Realpath realpath()

func Rename

func Rename(oldname, newname string) error

Rename rename()

func RunShell

func RunShell(exeStr string) (string, error)

RunShell 运行shell脚本

func Stat

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

Stat stat()

func StoreGobData

func StoreGobData(data interface{}, fileName string) error

StoreGobData store gob data

func Touch

func Touch(filename string) (bool, error)

Touch touch()

func Unlink(filename string) error

Unlink unlink()

Types

This section is empty.

Jump to

Keyboard shortcuts

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