file

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFile added in v0.3.2

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 added in v0.3.2

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

func ComparisonHash added in v0.2.10

func ComparisonHash(data []byte, hash string) bool

Comparison data hash

func CopyDir added in v0.2.9

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

Dir copies a whole directory recursively

func CopyFile added in v0.2.9

func CopyFile(src, dst, style string) error

File copies a single file from src to dst

func CopySingleFile added in v0.3.3

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 added in v0.2.10

func CreateFileAndWriteContent(path string, content string) error

func DataLength added in v0.2.10

func DataLength(length int) []byte

get data byte length

func DirSizeB added in v0.3.2

func DirSizeB(path string) (int64, error)

getFileSize get file size by path(B)

func Exists

func Exists(path string) bool

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

func GetBlockInfo added in v0.2.10

func GetBlockInfo(fileSize int64) (blockSize int, length int)

Get info of block

func GetCompressionAlgorithm added in v0.3.2

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

func GetExt

func GetExt(fileName string) string

GetExt get the file ext

func GetFileOrDirSize added in v0.3.2

func GetFileOrDirSize(path string) (int64, error)

func GetHashByContent added in v0.2.10

func GetHashByContent(data []byte) string

get the hash of the data

func GetHashByPath added in v0.2.10

func GetHashByPath(path string) string

get the hash of the data

func GetImage added in v0.3.1

func GetImage(path string, width, height int) ([]byte, error)

func GetImageExt added in v0.3.3

func GetImageExt(p string) (string, error)

* * @description:get a image's ext * @param {string} path "file path" * @return {string} ext "file ext" * @return {error} err "error info"

func GetImageExtByName added in v0.3.3

func GetImageExtByName(p string) (string, error)

func GetNoDuplicateFileName added in v0.3.0

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 GetThumbnailByOwnerPhotos added in v0.3.1

func GetThumbnailByOwnerPhotos(path string) ([]byte, error)

func GetThumbnailByWebPhoto added in v0.3.1

func GetThumbnailByWebPhoto(path string, width, height int) ([]byte, error)

func ImageExtArray added in v0.3.3

func ImageExtArray() []string

func IsDir

func IsDir(path string) bool

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

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 added in v0.3.4

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(name string, dir 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 ParseFileHeader added in v0.4.3

func ParseFileHeader(h []byte, boundary []byte) (map[string]string, bool)

func ParseFromHead added in v0.4.3

func ParseFromHead(read_data []byte, read_total int, boundary []byte, stream io.ReadCloser) (map[string]string, []byte, error)

func PrefixLength added in v0.2.10

func PrefixLength(byteLength int) []byte

get prefix byte length

func RMDir

func RMDir(src string) error

RMDir remove a directory

func ReadFullFile

func ReadFullFile(path string) []byte

func ReadLine added in v0.3.5

func ReadLine(lineNumber int, path string) string

func ReadToBoundary added in v0.4.3

func ReadToBoundary(boundary []byte, stream io.ReadCloser, target io.WriteCloser) ([]byte, bool, error)

func RemoveAll added in v0.4.5

func RemoveAll(dir string) error

func SpliceFiles added in v0.2.10

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

最终拼接

func WriteToFullPath added in v0.3.7

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

func WriteToPath added in v0.2.10

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

Types

type ReadLineFromEnd

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

ReadLineFromEnd --

func NewReadLineFromEnd

func NewReadLineFromEnd(name string) (rd *ReadLineFromEnd, err error)

NewReadLineFromEnd --

func (*ReadLineFromEnd) Close

func (c *ReadLineFromEnd) Close() (err error)

Close --

func (*ReadLineFromEnd) ReadLine

func (c *ReadLineFromEnd) ReadLine() (line []byte, err error)

ReadLine 结尾包含'\n'

Jump to

Keyboard shortcuts

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