diff options
| author | BiSaXa <1669855+BiSaXa@users.noreply.github.com> | 2022-08-27 14:08:45 +0300 |
|---|---|---|
| committer | BiSaXa <1669855+BiSaXa@users.noreply.github.com> | 2022-08-27 14:08:45 +0300 |
| commit | 91098f97aad482885b0ecaf0ca67a12dac8b602c (patch) | |
| tree | c27a7db2f0043746e14d32fce239af8d42606fb7 /main.go | |
| parent | add LICENSE and README (diff) | |
| download | sdp.go-91098f97aad482885b0ecaf0ca67a12dac8b602c.tar.gz sdp.go-91098f97aad482885b0ecaf0ca67a12dac8b602c.tar.bz2 sdp.go-91098f97aad482885b0ecaf0ca67a12dac8b602c.zip | |
support for multiple demos in a folder as an argument
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 39 |
1 files changed, 29 insertions, 10 deletions
| @@ -1,6 +1,8 @@ | |||
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | ||
| 5 | "io/ioutil" | ||
| 4 | "log" | 6 | "log" |
| 5 | "os" | 7 | "os" |
| 6 | "parser/messages" | 8 | "parser/messages" |
| @@ -9,18 +11,35 @@ import ( | |||
| 9 | 11 | ||
| 10 | func main() { | 12 | func main() { |
| 11 | if len(os.Args) != 2 { | 13 | if len(os.Args) != 2 { |
| 12 | log.Fatal("Specifiy file in command line arguments.") | 14 | log.Fatal("Specify file in command line arguments.") |
| 13 | } | 15 | } |
| 14 | file, err := os.Open(os.Args[1]) | 16 | files, err := ioutil.ReadDir(os.Args[1]) |
| 15 | utils.CheckError(err) | 17 | if err != nil { // If it's not a directory |
| 16 | utils.HeaderOut(file) | 18 | file, err := os.Open(os.Args[1]) |
| 17 | for { | 19 | utils.CheckError(err) |
| 18 | code := messages.MessageTypeCheck(file) | 20 | utils.HeaderOut(file) |
| 19 | if code == 7 { | 21 | for { |
| 20 | messages.MessageTypeCheck(file) | 22 | code := messages.MessageTypeCheck(file) |
| 21 | break // TODO: Check last CustomData | 23 | if code == 7 { |
| 24 | messages.MessageTypeCheck(file) | ||
| 25 | break // TODO: Check last CustomData | ||
| 26 | } | ||
| 22 | } | 27 | } |
| 28 | defer file.Close() | ||
| 29 | } | ||
| 30 | for _, fileinfo := range files { // If it is a directory | ||
| 31 | file, err := os.Open(os.Args[1] + fileinfo.Name()) | ||
| 32 | utils.CheckError(err) | ||
| 33 | utils.HeaderOut(file) | ||
| 34 | for { | ||
| 35 | code := messages.MessageTypeCheck(file) | ||
| 36 | if code == 7 { | ||
| 37 | messages.MessageTypeCheck(file) | ||
| 38 | break // TODO: Check last CustomData | ||
| 39 | } | ||
| 40 | } | ||
| 41 | defer file.Close() | ||
| 23 | } | 42 | } |
| 24 | 43 | ||
| 25 | //defer file.Close() | 44 | fmt.Scanln() |
| 26 | } | 45 | } |