Documentation ¶
Index ¶
- Constants
- Variables
- func CompressImage(sourcePath string, targetPath string, format string, quality int) error
- func CompressImageExt(sourcePath string, targetPath string, format string, quality int, ...) error
- func CopyFile(src string, dst string) (int64, error)
- func CopyFileWithBuff(srcFile *os.File, dstFile *os.File, bufSize int) (int64, error)
- func CreateFolderIfNotExists(filePath string, perm os.FileMode)
- func FileExists(path string) bool
- func IsByteArrayEqual(a1 []byte, a2 []byte) bool
- func IsDir(path string) bool
- func IsFileType(ft *FileType, f *os.File) bool
- func NotDir(path string) bool
- func PathIsFileType(ft *FileType, p string) bool
- func SupportFormat(format string) bool
- type FileType
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
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 CopyFileWithBuff ¶ added in v1.0.2
CopyFileWithBuff 使用buff讲一个打开的文件复制到另一个打开的文件
func CreateFolderIfNotExists ¶
CreateFolderIfNotExists 创建临时文件路径,如果他不存在的话
func IsByteArrayEqual ¶ added in v1.0.3
IsByteArrayEqual 判断数组是否相等
func IsFileType ¶ added in v1.0.3
IsFileType 判断指定文件与文件类型是否匹配
func PathIsFileType ¶ added in v1.0.3
PathIsFileType 判断指定路径的文件是否与文件类型匹配
Types ¶
Click to show internal directories.
Click to hide internal directories.