dashfile

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package dashfile

文件及文件夹相关工具

File and folder related tools

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendFile

func AppendFile(srcFilePath, dstFilePath string) (writeen int, err error)

CopyFile @Editor robotyang at 2023

CopyFile 从src文件 读取内容 追加到 dst文件

@Param srcFilePath 来源文件路径

@Param dstFilePath 目标文件路径:文件存在则覆盖,不存在则创建

func CompareFileBySum

func CompareFileBySum(filePath1, filePath2 string) bool

CompareFileBySum @Editor robotyang at 2023

CompareFileBySum 通过计算文件签名,判断两个文件是否一致

func CopyFile

func CopyFile(srcFilePath, dstFilePath string) (writeen int64, err error)

CopyFile @Editor robotyang at 2023

CopyFile 从src文件 读取内容 拷贝到 dst文件

@Param srcFilePath 来源文件路径

@Param dstFilePath 目标文件路径:文件存在则覆盖,不存在则创建

func CreateOrOpen

func CreateOrOpen(filePath string) (*os.File, error)

CreateOrOpen @Editor robotyang at 2023

CreateOrOpen 重建或打开文件(会自动创建目录,文件存在则打开,不存在则创建)

func CreateOrReset

func CreateOrReset(filePath string) (*os.File, error)

CreateOrReset @Editor robotyang at 2023

CreateOrReset 重建文件(会自动创建目录,文件存在则清空,不存在则创建)

func GetFileList

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

GetFileList @Editor robotyang at 2023

GetFileList 递归获取目录下的所有子文件

func GetFileListAccept

func GetFileListAccept(path string, accept []string) ([]string, error)

GetFileListAccept @Editor robotyang at 2023

GetFileListAccept is a ...

func GetFileListExcept

func GetFileListExcept(path string, except []string) ([]string, error)

GetFileListExcept @Editor robotyang at 2023

GetFileListExcept is a ...

func GetFileListFilter

func GetFileListFilter(path string, accept, except []string) ([]string, error)

GetFileListFilter @Editor robotyang at 2023

GetFileListFilter 递归获取目录下的所有子文件(排除清单except > 保留清单accept)

func GetLastDir

func GetLastDir(path string) string

GetLastDir @Editor robotyang at 2023

GetLastDir 获取 最后一个 目录名

func GetLastDirWithCheck

func GetLastDirWithCheck(path string) (string, error)

GetLastDirWithCheck @Editor robotyang at 2023

GetLastDirWithCheck 先检查路径资源是否存在,存在则获取 最后一个目录名

func IsDir

func IsDir(path string) bool

IsDir @Editor robotyang at 2023

IsDir 判断 所给路径 是否存在 且为文件夹

func IsExist

func IsExist(path string) bool

IsExist @Editor robotyang at 2023

IsExist 判断 文件或文件夹 是否存在;

func IsFile

func IsFile(path string) bool

IsFile @Editor robotyang at 2023

IsFile 判断 所给路径 是否存在 且为文件

func OpenFile

func OpenFile(filePath string) (*os.File, error)

OpenFile @Editor robotyang at 2023

OpenFile 打开文件(是 os.OpenFile 别名)

func ReadByFile

func ReadByFile(file *os.File) ([]byte, error)

ReadByFile @Editor robotyang at 2023

ReadByFile 读取文件内容

func ReadByFilePath

func ReadByFilePath(filePath string) ([]byte, error)

ReadByFilePath @Editor robotyang at 2023

ReadByFilePath 读取文件内容

@ @Editor robotyang at 2023

@Reference https://haicoder.net/golang/golang-read.html

func RemoveAll

func RemoveAll(path string) error

RemoveAll @Editor robotyang at 2023

RemoveAll 删除文件或目录

在删除文件时,RemoveAll()和Remove()方法没有太大的区别;

在删除目录时,Remove()只能删除空目录,而RemoveAll()不受任何限制。

Types

This section is empty.

Jump to

Keyboard shortcuts

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