-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproj_auto_copy.go
88 lines (83 loc) · 1.88 KB
/
proj_auto_copy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//////////////////////////////////
// This script will automatically copy all the
// files from an ideal folder or input folder to
// the same directory as the binary
/////////////////////////////////
package main
import (
"fmt"
"io/ioutil"
"os"
)
//Takes in a param, c, which lets us know if we want to copy ideal files alongside the binary
func copy_ideal() {
if _, err := os.Stat(idealDir); os.IsNotExist(err) {
fmt.Println(idealDir + " doesn't exist. Aborting...")
return
}
ideal, _ := os.Getwd()
ideal += "/" + idealDir
fmt.Println(ideal)
err := os.Chdir(project_dir)
if err != nil {
fmt.Println(err)
}
files, err := ioutil.ReadDir("./")
if err != nil {
fmt.Println(err)
}
//loop through everybody's directory
for _, file := range files {
if !isDir(file) {
break
}
studentName := file.Name()
fmt.Println("Copying ideal files for: " + studentName)
err := os.Chdir(studentName + "/Feedback Attachment(s)")
if err != nil {
fmt.Println(err)
os.Chdir("../..")
continue
}
for _, f := range test_cases {
os.Link(ideal+"/"+f, "./"+f)
}
os.Chdir("../../")
}
os.Chdir("../")
}
func copy_inputs() {
if _, err := os.Stat(inputsDir); os.IsNotExist(err) {
fmt.Println(inputsDir + " doesn't exist. Aborting...")
return
}
trueInputsDir, _ := os.Getwd()
trueInputsDir += "/" + inputsDir
err := os.Chdir(project_dir)
if err != nil {
fmt.Println(err)
}
files, err := ioutil.ReadDir("./")
if err != nil {
fmt.Println(err)
}
//loop through everybody's directory
for _, file := range files {
if !isDir(file) {
break
}
studentName := file.Name()
fmt.Println("Copying inputs for: " + studentName)
err := os.Chdir(studentName + "/Feedback Attachment(s)")
if err != nil {
fmt.Println(err)
os.Chdir("../..")
continue
}
for _, f := range inputs {
os.Link(trueInputsDir+"/"+f, "./"+f)
}
os.Chdir("../../")
}
os.Chdir("../")
}