wutils

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 8 Imported by: 0

README

wutils

golang tools

Documentation

Index

Constants

View Source
const (
	DefaultFileMode     = 0766
	CopyWhenUnsupported = 1
)
View Source
const CopyFileBuffSize = 1024 * 4

CopyFileBuffSize 复制用的buff大小 4k

Variables

View Source
var BmpFile = CreateFileType("BmpFile", "bmp图片格式", []string{"bmp"}, []string{"BM"})
View Source
var GifFile = CreateFileType("GifFile", "gif图片格式", []string{"gif"}, []string{"GIF"})
View Source
var GzipFile = CreateFileType("GzipFile", "gzip格式压缩文件", []string{"gzip", "gz", "tgz"}, []string{"\x1F\x8B\x08"})
View Source
var JavaClassFile = CreateFileType("JavaClassFile", "Java类", []string{"class"}, []string{"\xCA\xFE\xBA\xBE"})
View Source
var JpegFile = CreateFileType("JpegFile", "jpeg图片格式", []string{"jpg", "jpeg"}, []string{"\xff\xd8\xff"})
View Source
var LinuxExecuteFile = CreateFileType("LinuxExecuteFile", "Linux可执行文件", []string{""}, []string{"\x7fELF"})
View Source
var Office03File = CreateFileType("Office03File", "Office97-2003文件", []string{"doc"}, []string{"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"})
View Source
var PdfFile = CreateFileType("PdfFile", "pdf文件", []string{"pdf"}, []string{"%PDF-"})
View Source
var PngFile = CreateFileType("PngFile", "png图片格式", []string{"png"}, []string{"\x89PNG"})
View Source
var RarFile = CreateFileType("RarFile", "rar格式压缩文件", []string{"rar"}, []string{"Rar!"})
View Source
var RpmFile = CreateFileType("RpmFile", "rpm格式文件", []string{"rpm"}, []string{"\xED\xAB\xEE\xDB"})
View Source
var RtfFile = CreateFileType("RtfFile", "rtf文件", []string{"rtf"}, []string{"{\\rtf"})
View Source
var WindowsExecuteFile = CreateFileType("WindowsExecuteFile", "Windows可执行文件", []string{"exe"}, []string{"MZ"})
View Source
var X7zFile = CreateFileType("X7zFile", "7z格式压缩文件", []string{"7z"}, []string{"7z\xBC\xAF\x27"})
View Source
var ZipFile = CreateFileType("ZipFile", "zip格式压缩文件", []string{"zip"}, []string{"PK\x03\x04"})

Functions

func CompressImage added in v1.0.1

func CompressImage(sourcePath string, targetPath string, format string, quality int) error

CompressImage 压缩图片

func CompressImageExt added in v1.0.1

func CompressImageExt(sourcePath string, targetPath string, format string, quality int, perm os.FileMode, unsupported int) error

CompressImageExt 压缩图片的扩展方法

func CopyFile added in v1.0.1

func CopyFile(src string, dst string) (int64, error)

CopyFile 复制文件

func CopyFileWithBuff added in v1.0.2

func CopyFileWithBuff(srcFile *os.File, dstFile *os.File, bufSize int) (int64, error)

CopyFileWithBuff 使用buff讲一个打开的文件复制到另一个打开的文件

func CreateFolderIfNotExists

func CreateFolderIfNotExists(filePath string, perm os.FileMode)

CreateFolderIfNotExists 创建临时文件路径,如果他不存在的话

func FileExists

func FileExists(path string) bool

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

func IsByteArrayEqual added in v1.0.3

func IsByteArrayEqual(a1 []byte, a2 []byte) bool

IsByteArrayEqual 判断数组是否相等

func IsDir

func IsDir(path string) bool

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

func IsFileType added in v1.0.3

func IsFileType(ft *FileType, f *os.File) bool

IsFileType 判断指定文件与文件类型是否匹配

func NotDir

func NotDir(path string) bool

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

func PathIsFileType added in v1.0.3

func PathIsFileType(ft *FileType, p string) bool

PathIsFileType 判断指定路径的文件是否与文件类型匹配

func SupportFormat added in v1.0.1

func SupportFormat(format string) bool

SupportFormat 是否支持图片格式

Types

type FileType added in v1.0.3

type FileType struct {
	Code        string
	Name        string
	Suffix      []string
	MagicNumber [][]byte
}

FileType 文件类型

func CreateFileType added in v1.0.3

func CreateFileType(code string, name string, suffix []string, magicNumberStrings []string) *FileType

CreateFileType 创建FileType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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