-
Notifications
You must be signed in to change notification settings - Fork 1
/
od.go
46 lines (37 loc) · 795 Bytes
/
od.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
package engine
// Management of output directory.
import (
"github.com/mumax/3/httpfs"
"strings"
)
var (
outputdir string // Output directory
InputFile string
)
func OD() string {
if outputdir == "" {
panic("output not yet initialized")
}
return outputdir
}
// SetOD sets the output directory where auto-saved files will be stored.
// The -o flag can also be used for this purpose.
func InitIO(inputfile, od string, force bool) {
if outputdir != "" {
panic("output directory already set")
}
InputFile = inputfile
if !strings.HasSuffix(od, "/") {
od += "/"
}
outputdir = od
if strings.HasPrefix(outputdir, "http://") {
httpfs.SetWD(outputdir + "/../")
}
LogOut("output directory:", outputdir)
if force {
httpfs.Remove(od)
}
_ = httpfs.Mkdir(od)
initLog()
}