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

Function IsProblemPackage

common/utils/binary.go:184–198  ·  view source on GitHub ↗

IsProblemPackage 判断是否是题目包

(filePath string)

Source from the content-addressed store, hash-verified

182
183// IsProblemPackage 判断是否是题目包
184func IsProblemPackage(filePath string) (bool, error) {
185 fp, err := os.OpenFile(filePath, os.O_RDONLY|syscall.O_NONBLOCK, 0)
186 if err != nil {
187 return false, errors.Errorf("open file error")
188 }
189 defer fp.Close()
190
191 var magic uint16 = 0
192 err = binary.Read(fp, binary.BigEndian, &magic)
193 if err != nil {
194 return false, err
195 }
196
197 return magic == constants.ProblemPackageMagicCode, nil
198}

Callers 4

UnpackProblemPackageFunction · 0.92
ReadProblemInfoFunction · 0.92
loadProblemConfigurationFunction · 0.92
InitProblemWorkDirFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected