Rev 37 | Rev 43 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 37 | Rev 38 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | // ============================================================================= |
11 | // ============================================================================= |
12 | // Functions |
12 | // Functions |
13 | // ============================================================================= |
13 | // ============================================================================= |
14 | 14 | ||
15 | func Usage(progname, mesg string) { |
15 | func Usage(progname, mesg string) { |
16 | log.Print ("Usage: " + progname + " directory") |
16 | log.Print("Usage: " + progname + " directory") |
17 | log.Fatal (mesg) |
17 | log.Fatal(mesg) |
18 | } |
18 | } |
19 | 19 | ||
20 | func traverse(s string) { |
20 | func traverse(s string) { |
21 | curdir, err := os.Getwd() |
21 | curdir, err := os.Getwd() |
22 | if err := os.Chdir(s); err != nil { |
22 | if err := os.Chdir(s); err != nil { |
Line 54... | Line 54... | ||
54 | // MAIN |
54 | // MAIN |
55 | // ============================================================================= |
55 | // ============================================================================= |
56 | 56 | ||
57 | func main() { |
57 | func main() { |
58 | progname := os.Args[0] |
58 | progname := os.Args[0] |
59 | if len(os.Args) < 2 { |
59 | if len(os.Args) == 2 { |
- | 60 | directory := os.Args[1] |
|
- | 61 | fi, err := os.Stat(directory) |
|
- | 62 | if err != nil { |
|
- | 63 | _ = err // ugly hack to allow not using the err variable |
|
- | 64 | Usage(progname, "ERROR: Not a directory : " + directory) |
|
- | 65 | } |
|
- | 66 | if fi.IsDir() { |
|
- | 67 | start_traverse(directory) |
|
- | 68 | } else { |
|
- | 69 | Usage(progname, "ERROR: Not a directory : " + directory) |
|
- | 70 | } |
|
- | 71 | } else { |
|
60 | Usage(progname, "ERROR: 1 argument expected") |
72 | Usage(progname, "ERROR: 1 argument expected") |
61 | } |
73 | } |
62 | directory := os.Args[1] |
- | |
63 | fi, err := os.Stat(directory) |
- | |
64 | if err != nil { |
- | |
65 | _ = err // ugly hack to allow not using the err variable |
- | |
66 | Usage(progname, "ERROR: Not a directory : " + directory) |
- | |
67 | } |
- | |
68 | if fi.IsDir() { |
- | |
69 | start_traverse(directory) |
- | |
70 | } else { |
- | |
71 | Usage(progname, "ERROR: Not a directory : " + directory) |
- | |
72 | } |
- | |
73 | - | ||
74 | } |
74 | } |