()
| 97 | } |
| 98 | |
| 99 | func (p *PathIterator) Next() PathItem { |
| 100 | p.init() |
| 101 | if p.cursor >= len(p.path) { |
| 102 | return emptyPathItem |
| 103 | } |
| 104 | var item PathItem |
| 105 | index := strings.Index(p.path[p.cursor:], pathSep) |
| 106 | if index >= 0 { |
| 107 | item = PathItem{ |
| 108 | Name: p.path[p.cursor : p.cursor+index], |
| 109 | IsDirectory: true, |
| 110 | } |
| 111 | p.cursor = p.cursor + index + 1 |
| 112 | } else { |
| 113 | item = PathItem{ |
| 114 | Name: p.path[p.cursor:], |
| 115 | IsDirectory: false, |
| 116 | } |
| 117 | p.cursor = len(p.path) |
| 118 | } |
| 119 | return item |
| 120 | } |
| 121 | |
| 122 | func NewPathIterator(path string) PathIterator { |
| 123 | return PathIterator{ |
no test coverage detected