|
8 | 8 | "encoding/xml"
|
9 | 9 | "fmt"
|
10 | 10 | "io"
|
11 |
| - "io/ioutil" |
12 | 11 | "math"
|
13 | 12 | "os"
|
14 | 13 | "path/filepath"
|
@@ -423,14 +422,14 @@ func readin(jobs <-chan string, results chan<- interface{}, wg *sync.WaitGroup,
|
423 | 422 | if err == nil {
|
424 | 423 | results <- xmlResult{filePath: filePath, content: xmlContent}
|
425 | 424 | } else {
|
426 |
| - fmt.Fprintln(os.Stderr, "Import of", filePath, "failed") |
| 425 | + fmt.Fprintln(os.Stderr, "Import of", filePath, "failed", err.Error()) |
427 | 426 | }
|
428 | 427 | case ".mdoc":
|
429 | 428 | mdocContent, err := process_mdoc(filePath)
|
430 | 429 | if err == nil {
|
431 | 430 | results <- mdocResult{content: mdocContent}
|
432 | 431 | } else {
|
433 |
| - fmt.Fprintln(os.Stderr, "Import of", filePath, "failed") |
| 432 | + fmt.Fprintln(os.Stderr, "Import of", filePath, "failed", err.Error()) |
434 | 433 | }
|
435 | 434 | default:
|
436 | 435 | fmt.Fprintf(os.Stderr, "Unknown file type: %s\n", filePath)
|
@@ -519,15 +518,21 @@ func startProgressReporter(progressTracker *ProgressTracker) {
|
519 | 518 | func collectAllFiles(directories []string) ([]string, error) {
|
520 | 519 | var allFiles []string
|
521 | 520 | for _, dir := range directories {
|
522 |
| - files, err := ioutil.ReadDir(dir) |
523 |
| - if err != nil { |
524 |
| - return nil, err |
525 |
| - } |
526 |
| - for _, file := range files { |
527 |
| - if !file.IsDir() && !isHidden(file.Name()) && (filepath.Ext(file.Name()) == ".xml" || filepath.Ext(file.Name()) == ".mdoc") { |
528 |
| - allFiles = append(allFiles, filepath.Join(dir, file.Name())) |
| 521 | + err := filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error { |
| 522 | + if err != nil { |
| 523 | + return err |
| 524 | + } |
| 525 | + file, err := os.Stat(path) |
| 526 | + if err == nil && !file.IsDir() && !isHidden(file.Name()) && (filepath.Ext(file.Name()) == ".xml" || filepath.Ext(file.Name()) == ".mdoc") { |
| 527 | + allFiles = append(allFiles, path) |
529 | 528 | }
|
| 529 | + return err |
| 530 | + }) |
| 531 | + |
| 532 | + if err != nil { |
| 533 | + fmt.Printf("Error collecting files in path %q: %s\n", dir, err.Error()) |
530 | 534 | }
|
| 535 | + |
531 | 536 | }
|
532 | 537 | return allFiles, nil
|
533 | 538 | }
|
|
0 commit comments