| 1 |
/* |
| 2 |
Package fsnoder allows to create merkletrie noders that resemble file |
| 3 |
systems, from human readable string descriptions. Its intended use is |
| 4 |
generating noders in tests in a readable way. |
| 5 |
|
| 6 |
For example: |
| 7 |
|
| 8 |
root, _ = New("(a<1> b<2>, B(c<3> d()))") |
| 9 |
|
| 10 |
will create a noder as follows: |
| 11 |
|
| 12 |
root - "root" is an unnamed dir containing "a", "b" and "B". |
| 13 |
/ | \ - "a" is a file containing the string "1". |
| 14 |
/ | \ - "b" is a file containing the string "2". |
| 15 |
a b B - "B" is a directory containing "c" and "d". |
| 16 |
/ \ - "c" is a file containing the string "3". |
| 17 |
c d - "D" is an empty directory. |
| 18 |
|
| 19 |
Files are expressed as: |
| 20 |
|
| 21 |
- one or more letters and dots for the name of the file |
| 22 |
|
| 23 |
- a single number, between angle brackets, for the contents of the file. |
| 24 |
|
| 25 |
- examples: a<1>, foo.go<2>. |
| 26 |
|
| 27 |
Directories are expressed as: |
| 28 |
|
| 29 |
- one or more letters for the name of the directory. |
| 30 |
|
| 31 |
- its elements between parents, separated with spaces, in any order. |
| 32 |
|
| 33 |
- (optionally) the root directory can be unnamed, by skiping its name. |
| 34 |
|
| 35 |
Examples: |
| 36 |
|
| 37 |
- D(a<1> b<2>) : two files, "a" and "b", having "1" and "2" as their |
| 38 |
respective contents, inside a directory called "D". |
| 39 |
|
| 40 |
- A() : An empty directory called "A". |
| 41 |
|
| 42 |
- A(b<>) : An directory called "A", with an empty file inside called "b": |
| 43 |
|
| 44 |
- (b(c<1> d(e<2>)) f<>) : an unamed directory containing: |
| 45 |
|
| 46 |
├── b --> directory |
| 47 |
│ ├── c --> file containing "1" |
| 48 |
│ └── d --> directory |
| 49 |
│ └── e --> file containing "2" |
| 50 |
└── f --> empty file |
| 51 |
*/ |
| 52 |
package fsnoder |