gfx

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 12 Imported by: 8

README

gfx

Golang文件操作扩展库,包含工作和生活中关于文件操作的各种有用的使用方法,包括

  • 更友好的API
  • 文件创建
  • 文件删除
  • 文件复制
  • 一切皆可配置
    • 文件名
    • 扩展名
    • 文件名匹配模式
    • 匹配方法

感谢

jetbrains-variant-4.png

Documentation

Index

Constants

View Source
const (
	CheckTypeAll checkType = 1
	CheckTypeAny checkType = 2
)
View Source
const (
	// TypeFile 文件
	TypeFile _type = 1
	// TypeDir 目录
	TypeDir _type = 2
)
View Source
const (
	// WriteModeSkip 跳过
	WriteModeSkip writeMode = 1
	// WriteModeOverride 覆盖
	WriteModeOverride writeMode = 2
	// WriteModeError 返回错误
	WriteModeError writeMode = 3
	// WriteModeRename 重命名
	WriteModeRename writeMode = 4
)

Variables

This section is empty.

Functions

func All

func All(dir string, opts ...walkOption) (filenames []string, err error)

All 取得目录下所有文件,包含子目录 默认文件匹配所有文件

func ContentType

func ContentType(path string) (contentType string, err error)

ContentType 获得文件的类型

func ContentTypeForFile

func ContentTypeForFile(file *os.File) (contentType string, err error)

ContentTypeForFile 获得文件的类型

func Copy

func Copy(from string, to string, opts ...copyOption) (err error)

Copy 文件复制 如果文件有冲突,默认使用覆盖模式

func Create

func Create(path string, opts ...option) (err error)

Create 创建文件或者目录 默认创建文件 默认权限是0777

func Delete

func Delete(filename string) error

Delete 删除文件或者目录

func Dir

func Dir() *optionType

func Exists

func Exists(path string, opts ...existsOption) (final string, exists bool)

Exists 判断文件是否存在

func Ext

func Ext(ext string) *optionExtensions

Ext 文件扩展名

func Extension added in v0.0.5

func Extension(extension string) *optionExtensions

Extension 文件扩展名

func Extensions added in v0.0.5

func Extensions(extensions ...string) *optionExtensions

Extensions 文件扩展名列表

func File

func File() *optionType

File 配置类型为文件

func Filename

func Filename(path string, opts ...nameOption) (filename string)

Filename 获得文件名称

func Is

func Is(path string, opts ...isOption) (is bool, err error)

Is 判断所给路径是否为文件或者目录

func Matchable

func Matchable(matchable matchable) *optionMatchable

Matchable 配置文件是否可被浏览

func Mode

func Mode(mode os.FileMode) *optionMode

Mode 配置权限

func NewExistsOptions added in v0.0.4

func NewExistsOptions(opts ...existsOption) []existsOption

NewExistsOptions 快捷方式,解决接口不对外暴露不能引用的问题

func NewFilename

func NewFilename(original string) (new string)

NewFilename 新文件名,在避免文件名冲突的情况下

func NewOwner

func NewOwner(uid int, gid int) *owner

NewOwner 创建拥有者

func Path added in v0.0.4

func Path(path string) *optionPaths

Path 路径

func Paths added in v0.0.5

func Paths(paths ...string) *optionPaths

Paths 路径列表

func Pattern

func Pattern(pattern string) *optionPattern

Pattern 模式匹配

func Rename

func Rename(from string, to string) error

Rename 重命名文件或者目录

func Type

func Type(_type _type) *optionType

Type 配置类型

func ValidFilename

func ValidFilename(filename string) bool

ValidFilename 有效文件名(Windows标准)

func ValidFilepath

func ValidFilepath(filepath string) bool

ValidFilepath 有效文件夹名

func Walk added in v0.0.6

func Walk(dir string, handler walkHandler, opts ...walkOption) (err error)

Walk 浏览目录 默认文件匹配所有文件

func WriteMode

func WriteMode(mode writeMode) *optionWriteMode

WriteMode 配置复制模式

Types

type Size

type Size string

Size 默认大小:B

func (*Size) Size

func (s *Size) Size() (num int64)

Size 返回多少字节

Jump to

Keyboard shortcuts

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