函数定义#
Compress#
详细描述#
Compress(zipName string, filenames ...string) error
参数名 | 参数类型 | 参数解释 |
---|
zipName | string | |
filenames | ...string | |
返回值#
CompressRaw#
详细描述#
CompressRaw compresses a map to a zip file
Example:
zipBytes = zip.CompressRaw({ "a.txt": "hello", "b.txt": "world", })~ zipBytes2, err = zip.CompressRaw({ "a.txt": "hello", "b.txt": file.ReadFile("/tmp/external-file-name.txt")~ })
CompressRaw(i any) ([]byte, error)
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []byte | |
r2 | error | |
Decompress#
详细描述#
解压
Decompress(zipFile string, dest string) error
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
dest | string | |
返回值#
ExtractByPattern#
详细描述#
ExtractByPattern 根据文件名模式提取文件(支持通配符)
ExtractByPattern(zipFile string, pattern string) ([]*ExtractResult, error)
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
pattern | string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*ExtractResult | |
r2 | error | |
ExtractByPatternFromRaw#
详细描述#
ExtractByPatternFromRaw 从原始数据根据文件名模式提取文件
ExtractByPatternFromRaw(raw any, pattern string) ([]*ExtractResult, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
pattern | string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*ExtractResult | |
r2 | error | |
ExtractFile#
详细描述#
ExtractFile 从 ZIP 文件中提取单个文件
ExtractFile(zipFile string, targetFile string) ([]byte, error)
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
targetFile | string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []byte | |
r2 | error | |
ExtractFileFromRaw#
详细描述#
ExtractFileFromRaw 从 ZIP 原始数据中提取单个文件
ExtractFileFromRaw(raw any, targetFile string) ([]byte, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
targetFile | string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []byte | |
r2 | error | |
ExtractFiles#
详细描述#
ExtractFiles 从 ZIP 文件中并发提取多个文件
ExtractFiles(zipFile string, targetFiles []string) ([]*ExtractResult, error)
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
targetFiles | []string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*ExtractResult | |
r2 | error | |
ExtractFilesFromRaw#
详细描述#
ExtractFilesFromRaw 从 ZIP 原始数据中并发提取多个文件
ExtractFilesFromRaw(raw any, targetFiles []string) ([]*ExtractResult, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
targetFiles | []string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*ExtractResult | |
r2 | error | |
GrepPathRawRegexp#
详细描述#
GrepPathRawRegexp 使用正则表达式在原始数据中搜索文件路径
GrepPathRawRegexp(raw any, pattern string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
pattern | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
GrepPathRawSubString#
详细描述#
GrepPathRawSubString 使用子字符串在原始数据中搜索文件路径
GrepPathRawSubString(raw any, substring string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
substring | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
GrepPathRegexp#
详细描述#
GrepPathRegexp 使用正则表达式搜索文件路径
GrepPathRegexp(zipFile string, pattern string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
pattern | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
GrepPathSubString#
详细描述#
GrepPathSubString 使用子字符串搜索文件路径
GrepPathSubString(zipFile string, substring string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
substring | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
GrepRawRegexp#
详细描述#
GrepRawRegexp 使用正则表达式在 ZIP 原始数据中搜索
GrepRawRegexp(raw any, pattern string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
pattern | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
GrepRawSubString#
详细描述#
GrepRawSubString 使用子字符串在 ZIP 原始数据中搜索
GrepRawSubString(raw any, substring string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
substring | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
GrepRegexp#
详细描述#
GrepRegexp 使用正则表达式在 ZIP 文件中搜索
GrepRegexp(zipFile string, pattern string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
pattern | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
GrepSubString#
详细描述#
GrepSubString 使用子字符串在 ZIP 文件中搜索
GrepSubString(zipFile string, substring string, opts ...GrepOption) ([]*GrepResult, error)
参数名 | 参数类型 | 参数解释 |
---|
zipFile | string | |
substring | string | |
opts | ...GrepOption | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
r2 | error | |
MergeGrepResults#
详细描述#
MergeGrepResults 合并多个 GrepResult,将可以合并的结果合并在一起
MergeGrepResults(results []*GrepResult) []*GrepResult
参数名 | 参数类型 | 参数解释 |
---|
results | []*GrepResult | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*GrepResult | |
NewGrepSearcher#
详细描述#
NewZipGrepSearcher 创建一个新的 ZIP 搜索器(从文件)
NewGrepSearcher(zipFile string) (*ZipGrepSearcher, error)
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | *ZipGrepSearcher | |
r2 | error | |
NewGrepSearcherFromRaw#
详细描述#
NewZipGrepSearcherFromRaw 创建一个新的 ZIP 搜索器(从原始数据)
NewGrepSearcherFromRaw(raw any, filename ...string) (*ZipGrepSearcher, error)
参数名 | 参数类型 | 参数解释 |
---|
raw | any | |
filename | ...string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | *ZipGrepSearcher | |
r2 | error | |
RRFRankResults#
详细描述#
RRFRankGrepResults 使用 RRF 算法对 GrepResult 进行排序
Example:
results1 = zip.GrepRegexp("file.zip", "pattern1")~ results2 = zip.GrepSubString("file.zip", "keyword")~ allResults = append(results1, results2...) ranked = zip.RRFRankResults(allResults)~
RRFRankResults(results []*ziputil.GrepResult) []*ziputil.GrepResult
参数名 | 参数类型 | 参数解释 |
---|
results | []*ziputil.GrepResult | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | []*ziputil.GrepResult | |
Recursive#
详细描述#
Recursive Decompress decompresses a zip file to a directory
Example:
zip.Decompress("/tmp/abc.zip", (isDir, pathName, info) => { log.info("isDir: %v, pathName: %v, info: %v", isDir, pathName, info.Name()) })~
Recursive(i any, cb func(isDir bool, pathName string, info os.FileInfo) error) error
参数名 | 参数类型 | 参数解释 |
---|
i | any | |
cb | func(isDir bool, pathName string, info os.FileInfo) error | |
返回值#
RecursiveFromRaw#
详细描述#
RecursiveFromRaw decompresses a zip file to a directory
Example:
raw = file.ReadFile("/tmp/abc.zip")~ zip.RecursiveFromRawBytes(raw, (isDir, pathName, info) => { log.info("isDir: %v, pathName: %v, info: %v", isDir, pathName, info.Name()) })
RecursiveFromRaw(i any, cb func(isDir bool, pathName string, info os.FileInfo) error) error
参数名 | 参数类型 | 参数解释 |
---|
i | any | |
cb | func(isDir bool, pathName string, info os.FileInfo) error | |
返回值#
grepCaseSensitive#
详细描述#
grepCaseSensitive(i ...bool) GrepOption
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | GrepOption | |
grepContextLine#
详细描述#
grepContextLine(context int) GrepOption
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | GrepOption | |
grepExcludePathRegexp#
详细描述#
grepExcludePathRegexp(patterns ...string) GrepOption
参数名 | 参数类型 | 参数解释 |
---|
patterns | ...string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | GrepOption | |
grepExcludePathSubString#
详细描述#
grepExcludePathSubString(patterns ...string) GrepOption
参数名 | 参数类型 | 参数解释 |
---|
patterns | ...string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | GrepOption | |
grepIncludePathRegexp#
详细描述#
grepIncludePathRegexp(patterns ...string) GrepOption
参数名 | 参数类型 | 参数解释 |
---|
patterns | ...string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | GrepOption | |
grepIncludePathSubString#
详细描述#
grepIncludePathSubString(patterns ...string) GrepOption
参数名 | 参数类型 | 参数解释 |
---|
patterns | ...string | |
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | GrepOption | |
grepLimit#
详细描述#
grepLimit(limit int) GrepOption
返回值#
返回值(顺序) | 返回值类型 | 返回值解释 |
---|
r1 | GrepOption | |