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

Method SaveConfiguration

executor/structs.go:37–57  ·  view source on GitHub ↗

SaveConfiguration 保存评测会话

(userConfirm bool)

Source from the content-addressed store, hash-verified

35
36// SaveConfiguration 保存评测会话
37func (session *JudgeSession) SaveConfiguration(userConfirm bool) error {
38 if userConfirm {
39 fmt.Print("Save all the changed to config file? [y/N] ")
40 ans := ""
41 _, err := fmt.Scanf("%s", &ans)
42 if err != nil {
43 return nil // don't crash at EOF
44 }
45 if len(ans) > 0 && strings.ToLower(ans[:1]) != "y" {
46 return nil
47 }
48 }
49 err := ioutil.WriteFile(session.ConfigFile, []byte(utils.ObjectToJSONStringFormatted(session.JudgeConfig)), 0644)
50 if err != nil {
51 return err
52 }
53 if userConfirm {
54 fmt.Println("Saved!")
55 }
56 return nil
57}
58
59// NewSession 创建会话对象
60func NewSession(configFile string) (*JudgeSession, error) {

Callers 2

RunTestlibValidatorsFunction · 0.80
RunCheckerCasesFunction · 0.80

Calls 2

PrintMethod · 0.80

Tested by

no test coverage detected