MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / IsZipFile

Function IsZipFile

common/utils/binary.go:168–181  ·  view source on GitHub ↗

IsZipFile 判断是否是Zip文件

(filePath string)

Source from the content-addressed store, hash-verified

166
167// IsZipFile 判断是否是Zip文件
168func IsZipFile(filePath string) (bool, error) {
169 fp, err := os.OpenFile(filePath, os.O_RDONLY|syscall.O_NONBLOCK, 0)
170 if err != nil {
171 return false, errors.Errorf("open file error")
172 }
173 defer fp.Close()
174
175 var magic uint32 = 0
176 err = binary.Read(fp, binary.BigEndian, &magic)
177 if err != nil {
178 return false, err
179 }
180 return magic == constants.ZipArchiveMagicCode, nil
181}
182
183// IsProblemPackage 判断是否是题目包
184func IsProblemPackage(filePath string) (bool, error) {

Callers 3

UnpackProblemPackageFunction · 0.92
ReadProblemInfoFunction · 0.92
loadProblemConfigurationFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected