This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Commit b5144ff
committed
filesystem: add 'ReadDirRecursive()'
Add the 'ReadDirRecursive()' function to 'FileSystem' to facilitate easy
lookup of filesystem entries at a fixed depth from the root. In later
commits, this will be used to look up routes in the bundle server under the
'reporoot' on the filesystem.
'ReadDirRecursive()' takes three arguments:
* 'path': the root directory into which we want to recurse
* 'depth': the number of times to recurse into 'path'. A depth of 0 will
return nothing, a depth of 1 will return all entries inside 'path', a
depth of 2 will return all entries inside the subdirectories of 'path',
etc.
* 'strictDepth': a flag indicating whether to return only entries that are
*exactly 'depth' levels beneath 'path'. If 'false', 'ReadDirRecursive()'
will also include files and empty directories at depths less than 'depth'.
For example, consider the following directory tree:
.
├── another-dir/
│ └── testfile
├── myfile
├── org/
│ └── repo/
│ ├── deeper/
│ └── repofile
└── too-shallow/
'ReadDirRecursive(".", 2, true)' will return:
- ./another-dir/testfile
- ./org/repo/
Whereas 'ReadDirRecursive(".", 2, false)' will return:
- ./another-dir/testfile
- ./myfile
- ./org/repo/
- ./too-shallow/
Signed-off-by: Victoria Dye <vdye@github.com>1 parent 3783a2b commit b5144ff
2 files changed
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
38 | 63 | | |
39 | 64 | | |
40 | 65 | | |
| |||
43 | 68 | | |
44 | 69 | | |
45 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
46 | 80 | | |
47 | 81 | | |
48 | 82 | | |
| |||
173 | 207 | | |
174 | 208 | | |
175 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
199 | 204 | | |
200 | 205 | | |
201 | 206 | | |
| |||
0 commit comments