file

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 12 Imported by: 17

Documentation

Index

Constants

View Source
const EtcOsRelease string = "/etc/os-release"

about os release

View Source
const UsrLibOsRelease string = "/usr/lib/os-release"

Variables

This section is empty.

Functions

func AddFile

func AddFile(ar archiver.Writer, path, commonPath string) error

func CheckNotExist

func CheckNotExist(src string) bool

CheckNotExist check if the file exists

func CheckPermission

func CheckPermission(src string) bool

CheckPermission check if the file has permission

func CommonPrefix

func CommonPrefix(sep byte, paths ...string) string

func CopyDir

func CopyDir(src string, dst string, style string) error

Dir copies a whole directory recursively

func CopyFile

func CopyFile(src, dst, style string) error

File copies a single file from src to dst

func CopySingleFile

func CopySingleFile(src, dst, style string) error

*

  • @description:
  • @param {*} src
  • @param {*} dst
  • @param {string} style
  • @return {*}
  • @method:
  • @router:

func CreateFile

func CreateFile(path string) error

func CreateFileAndWriteContent

func CreateFileAndWriteContent(path string, content string) error

func DirSizeB

func DirSizeB(path string) (int64, error)

getFileSize get file size by path(B)

func Exists

func Exists(path string) bool

判断所给路径文件/文件夹是否存在

func FindFirstFile

func FindFirstFile(root string, filename string) string

func GetCompressionAlgorithm

func GetCompressionAlgorithm(t string) (string, archiver.Writer, error)

func GetExt

func GetExt(fileName string) string

GetExt get the file ext

func GetFileOrDirSize

func GetFileOrDirSize(path string) (int64, error)

func GetNoDuplicateFileName

func GetNoDuplicateFileName(fullPath string) string

Check for duplicate file names

func GetSize

func GetSize(f multipart.File) (int, error)

GetSize get the file size

func IsDir

func IsDir(path string) bool

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

func IsDirEmpty

func IsDirEmpty(name string) (bool, error)

func IsFile

func IsFile(path string) bool

判断所给路径是否为文件

func IsNotExistCreateFile

func IsNotExistCreateFile(src string) error

IsNotExistMkDir create a directory if it does not exist

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

IsNotExistMkDir create a directory if it does not exist

func MkDir

func MkDir(src string) error

MkDir create a directory

func MoveFile

func MoveFile(sourcePath, destPath string) error

func MustOpen

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

MustOpen maximize trying to open the file

func NameAccumulation added in v0.4.2

func NameAccumulation(path string) string

func Open

func Open(name string, flag int, perm os.FileMode) (*os.File, error)

Open a file according to a specific mode

func ParseFile added in v0.4.1

func ParseFile(filename string) (lines []string, err error)

func ParseLine added in v0.4.1

func ParseLine(line string, sep string) (key string, value string, err error)

func RMDir

func RMDir(src string) error

RMDir remove a directory

func ReadFile added in v0.4.1

func ReadFile(filename string) (osrelease map[string]string, err error)

func ReadFullFile

func ReadFullFile(path string) []byte

func ReadOSRelease added in v0.4.1

func ReadOSRelease() (osrelease map[string]string, err error)

Read and return os-release, trying EtcOsRelease, followed by UsrLibOsRelease. err will contain an error message if neither file exists or failed to parse

func SpliceFiles

func SpliceFiles(dir, path string, length int, startPoint int) error

最终拼接

func WriteToFullPath added in v0.4.0

func WriteToFullPath(data []byte, fullPath string, perm fs.FileMode) error

func WriteToPath

func WriteToPath(data []byte, path, name string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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