file

package
v0.0.0-...-bcb142e Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigUtil

type ConfigUtil struct{}

type FileInfo

type FileInfo struct {
	GsName    string      `json:"sName"`    //名称
	GsPath    string      `json:"sPath"`    //路径
	GiDir     int         `json:"iDir"`     //是否目录
	GiSize    int64       `json:"iSize"`    //大小
	GdTime    string      `json:"dTime"`    //修改时间
	Gchildren []*FileInfo `json:"children"` //子文件
}

*

  • 文件信息信息
  • @author HuangXinBian

type FileUtil

type FileUtil struct{}

func (FileUtil) CopyDir

func (FileUtil) CopyDir(sourceDirPath, targetDirPath string) (bool, error)

复制文件夹

func (FileUtil) CreateFile

func (fu FileUtil) CreateFile(filePath string) (bool, error)

调用os.MkdirAll递归创建文件夹

func (FileUtil) CreateFileDir

func (fu FileUtil) CreateFileDir(filePath string) (bool, error)

*

  • 创建文件所在文件夹
  • 注意:必须是文件,否则只能创建出上级路径
  • @param filePath 文件路径
  • @return bool:是否成功(如果路径已经存在则不会创建,但返回true); error:错误信息

func (FileUtil) CurrentDir

func (fu FileUtil) CurrentDir() string

*

  • 获取当前执行程序目录
  • @return string 路径

func (FileUtil) Del

func (fu FileUtil) Del(path string) (bool, error)

删除文件

func (FileUtil) DelFiles

func (fu FileUtil) DelFiles(dir string, delDir bool) error

删除文件(文件夹)

func (FileUtil) Exists

func (fu FileUtil) Exists(path string) (bool, error)

*

  • 判断文件夹是否存在
  • @param filePath 文件路径
  • @return bool, error:是否存在(存在返回true); error:错误信息

func (FileUtil) GetAllFiles

func (fu FileUtil) GetAllFiles(dirPth string) (files []string, err error)

获取指定目录下的所有文件,包含子目录下的文件

func (FileUtil) GetFilesAndDirs

func (fu FileUtil) GetFilesAndDirs(dirPth string) (files []string, dirs []string, err error)

获取指定目录下的所有文件和目录

func (FileUtil) GetFilesTree

func (fu FileUtil) GetFilesTree(rootName string, delRoot bool) *MsgEmity

*

  • 取文件夹信息树
  • rootName 根节点
  • delRoot 路径中隐藏根路径

func (FileUtil) IsDir

func (fu FileUtil) IsDir(path string) bool

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

func (FileUtil) IsExist

func (fu FileUtil) IsExist(path string) bool

判断所给路径文件/文件夹是否存在(返回true是存在)

func (FileUtil) IsFile

func (fu FileUtil) IsFile(path string) bool

判断所给路径是否为文件

func (FileUtil) Read

func (fu FileUtil) Read(path string) *MsgEmity

读取文件,返回[]byte

func (FileUtil) ReadFromFile

func (fu FileUtil) ReadFromFile(path string) *MsgEmity

读取文件

func (FileUtil) Save

func (fu FileUtil) Save(text string, path string) (bool, error)

保存文件内容

type RarUtil

type RarUtil struct {
}

func (RarUtil) Read

func (RarUtil) Read(source string, iIndex int) *MsgEmity

*

  • 读取指定(序号)文件
  • source 源文件
  • iIndex 序号
  • *MsgEmity (content []byte, fileName string)

func (RarUtil) ReadByIndex

func (ru RarUtil) ReadByIndex(source string, iIndex int) *MsgEmity

*

  • 读取指定(序号)文件
  • source 源文件
  • iIndex 序号
  • *MsgEmity (content []byte, fileName string)

func (RarUtil) ReadByName

func (RarUtil) ReadByName(source, sName string) *MsgEmity

*

  • 读取指定(名称)文件
  • source 源文件
  • iIndex 序号
  • *MsgEmity (content []byte, fileName string)

func (RarUtil) Unpack

func (RarUtil) Unpack(source, targe string) *MsgEmity

*

  • 解压文件
  • source 源文件
  • targe 目标路径
  • *MsgEmity (int, msg)

type ZipUtil

type ZipUtil struct {
}

func (ZipUtil) Create

func (zu ZipUtil) Create(source string, target string) *MsgEmity

*

  • 打包成zip文件
  • src 源文件夹
  • target 目标文件名

func (ZipUtil) LoadCount

func (zu ZipUtil) LoadCount(source string) *MsgEmity

*

  • 读取压缩文件里的文件数
  • source 源文件
  • iIndex 序号
  • *MsgEmity (content []byte, fileName string)

func (ZipUtil) ReadByIndex

func (zu ZipUtil) ReadByIndex(source string, iIndex int) *MsgEmity

*

  • 读取指定(序号)文件
  • source 源文件
  • iIndex 序号
  • *MsgEmity (content []byte, fileName string)

func (ZipUtil) ReadByName

func (zu ZipUtil) ReadByName(source, sName string) *MsgEmity

*

  • 读取指定(名称)文件
  • source 源文件
  • sName 名称
  • *MsgEmity (content []byte, fileName string)

func (ZipUtil) UnZip

func (zu ZipUtil) UnZip(source string, target string) *MsgEmity

*

  • 解压zip文件
  • src 源文件夹
  • target 目标文件夹
  • *MsgEmity (int, msg)

Jump to

Keyboard shortcuts

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