fs

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 19 Imported by: 3

Documentation

Overview

inspiring from https://www.youtube.com/watch?v=1B71SL6Y0kA

Index

Constants

View Source
const DownloadKey = ".downloading"
View Source
const PathSeparator = string(os.PathSeparator)

Variables

View Source
var FileTypeMap = map[string]FileType{
	".txt": Txt,
	".doc": Doc,
}

Functions

func Check added in v1.1.0

func Check(src string) error

func CheckExist

func CheckExist(src string) bool

func CheckNotExist

func CheckNotExist(src string) bool

func CheckPermission

func CheckPermission(src string) bool

func CopyDir

func CopyDir(src, dst string) error

CopyDir 递归复制目录

func CopyFile

func CopyFile(src, dst string) error

CopyFile : General Approach

func CreatFileFromReader added in v1.1.0

func CreatFileFromReader(filepath string, reader io.Reader) error

func CreatFileFromReaderIfNotExists added in v1.1.0

func CreatFileFromReaderIfNotExists(filepath string, reader io.Reader) error

func Create

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

func Exist added in v1.1.0

func Exist(filepath string) bool

func FindFile

func FindFile(path string) (string, error)

path和filepath两个包,filepath文件专用

func FindFiles

func FindFiles(path string, deep int8, num int) ([]string, error)

func FindFiles2

func FindFiles2(path string, deep int8, num int) ([]string, error)

path和filepath两个包,filepath文件专用

func GetFileCreateTime

func GetFileCreateTime(path string) int64

func GetLogFilePath

func GetLogFilePath(RuntimeRootPath, LogSavePath string) string

func GetMd5Name added in v1.1.0

func GetMd5Name(name string) string

func IsNotExistMkdir

func IsNotExistMkdir(src string) error

func LastFile

func LastFile(dir string) (os.FileInfo, map[string]os.FileInfo, error)

LastFile 当前目录最后一个创建的文件

func Md5

func Md5(path string) (string, error)

func Mkdir

func Mkdir(src string) error

func MkdirAll

func MkdirAll(src string) error

func MustOpen

func MustOpen(fileName, filePath string) (*os.File, error)

func NotExist

func NotExist(filepath string) bool

func OpenLogFile

func OpenLogFile(fileName, filePath string) (*os.File, error)

func RangeDir

func RangeDir(dir string, callback func(dir string, entities []os.DirEntry) error) error

遍历根目录中的每个文件,为每个目录下的文件集合调用callback,不包括文件

func RangeFile added in v1.1.0

func RangeFile(dir string, callback func(dir string, entry os.DirEntry) error) error

遍历根目录中的每个文件,为每个文件调用callback,不包括目录,与filepath.WalkDir不同的是,filepath.WalkDir会对目录同样调用,RangeFile不会,且回调函数的参数不同,filepath.WalkDir的第一个参数是文件完整路径,RangeFile是文件所在目录的路径

func SafeCopyFile

func SafeCopyFile(src, dst string) error

SafeCopyFile : Error handling by abstraction

func Write

func Write(data []byte, filename string) (n int, err error)

func WriteBuffer added in v1.1.0

func WriteBuffer(buf *bytes.Buffer, filename string) (n int, err error)

Types

type Dir

type Dir string

func (Dir) Open

func (d Dir) Open(name string) (*os.File, error)

type DirEntities

type DirEntities []os.DirEntry

func (DirEntities) Len

func (e DirEntities) Len() int

func (DirEntities) Less

func (e DirEntities) Less(i, j int) bool

func (DirEntities) Swap

func (e DirEntities) Swap(i, j int)

type FileType

type FileType int
const (
	Unknown FileType = iota
	Txt
	Doc
	Docx
	Xls
	Xlsx
)

type SafeCopy

type SafeCopy struct {
	// contains filtered or unexported fields
}

func (*SafeCopy) Close

func (c *SafeCopy) Close()

func (*SafeCopy) Copy

func (c *SafeCopy) Copy()

func (*SafeCopy) Create

func (c *SafeCopy) Create(dst string)

Directories

Path Synopsis
watch

Jump to

Keyboard shortcuts

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