/
main.go
72 lines (68 loc) · 1.38 KB
/
main.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
// 29 december 2012
package main
import (
"fmt"
"os"
"code.google.com/p/rsc/fuse"
"log"
)
func (g *Game) Find() (found bool, err error) {
// did we find this already?
if g.Found {
return true, nil
}
found, err = g.findROMs()
if err != nil {
log.Printf("error finding ROMs for game %s: %v\n", g.Name, err)
return
} else if !found {
return
}
found, err = g.findCHDs()
if err != nil {
log.Printf("error finding CHDs for game %s: %v\n", g.Name, err)
return
} else if !found {
return
}
g.Found = true
return
}
func main() {
if len(os.Args) != 4 {
fmt.Fprintf(os.Stderr, "usage: %s mamexml dirlistfile mountpoint\n", os.Args[0])
os.Exit(1)
}
fstree := getGames(os.Args[1])
getDirList(os.Args[2])
mount, err := fuse.Mount(os.Args[3])
if err != nil {
log.Fatalf("error launching FUSE file system: %v", err)
}
fmt.Println("starting server")
mount.Serve(fstree)
}
func x() {
if len(os.Args) != 4 {
fmt.Fprintf(os.Stderr, "usage: %s mamexml dirlistfile mountpoint\n", os.Args[0])
os.Exit(1)
}
getGames(os.Args[1])
getDirList(os.Args[2])
// startServer()
for _, g := range games {
fmt.Printf("%12s ", g.Name)
if g.Found { // already found (parent)
fmt.Println(g.ROMLoc)
continue
}
found, err := g.Find()
if err != nil {
fmt.Printf("error: %v\n", err)
} else if !found {
fmt.Println("not found")
} else {
fmt.Println(g.ROMLoc)
}
}
}