createFilesTree create a random files tree
(root string, maxDepth, depth int)
| 57 | |
| 58 | // createFilesTree create a random files tree |
| 59 | func createFilesTree(root string, maxDepth, depth int) error { |
| 60 | // create more one dir if don't achieve the maxDepth |
| 61 | if depth < maxDepth { |
| 62 | newDir, err := ioutil.TempDir(root, fmt.Sprintf("cpdir_%d_", depth)) |
| 63 | if err != nil { |
| 64 | return err |
| 65 | } |
| 66 | |
| 67 | if err = createFilesTree(newDir, maxDepth, depth+1); err != nil { |
| 68 | return err |
| 69 | } |
| 70 | } |
| 71 | // generate random files |
| 72 | for i := 0; i < maxFiles; i++ { |
| 73 | f, err := randomFile(root, fmt.Sprintf("cpfile_%d_", i)) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | f.Close() |
| 78 | } |
| 79 | |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | // readDirs get the path and fname each file of dir pathToRead |
| 84 | // set on that structure fname:[fpath1, fpath2] |
no test coverage detected
searching dependent graphs…