file

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 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

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 ComparisonHash

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

Comparison data hash

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 DataLength

func DataLength(length int) []byte

get data byte length

func DirSizeB

func DirSizeB(path string) (int64, error)

getFileSize get file size by path(B)

func Exists

func Exists(path string) bool

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

func GetBlockInfo

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

Get info of block

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 GetHashByContent

func GetHashByContent(data []byte) string

get the hash of the data

func GetHashByPath

func GetHashByPath(path string) string

get the hash of the data

func GetImage

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

func GetImageExt

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

func GetImageExtByName(p string) (string, 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 GetThumbnailByOwnerPhotos

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

func GetThumbnailByWebPhoto

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

func ImageExtArray

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

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

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

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

func ParseFromHead

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

func PrefixLength

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

func ReadLine(lineNumber int, path string) string

func ReadToBoundary

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

func RemoveAll

func RemoveAll(dir string) error

func SpliceFiles

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

最终拼接

func WriteToFullPath

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

func WriteToPath

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