MCPcopy
hub / github.com/u-root/u-root / createFilesTree

Function createFilesTree

cmds/cp/cp_test.go:59–81  ·  view source on GitHub ↗

createFilesTree create a random files tree

(root string, maxDepth, depth int)

Source from the content-addressed store, hash-verified

57
58// createFilesTree create a random files tree
59func 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]

Callers 3

TestCpRecursiveFunction · 0.85
TestCpRecursiveNewFunction · 0.85
TestCpRecursiveMultipleFunction · 0.85

Calls 2

randomFileFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…