Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ echo f
- `parseutils.parseUntil` has now a different behaviour if the `until` parameter is
empty. This was required for intuitive behaviour of the strscans module
(see bug #13605).
- `std/oswalkdir` was buggy, it's now deprecated and reuses `std/os` procs


## Language additions
Expand Down
31 changes: 4 additions & 27 deletions lib/pure/oswalkdir.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,7 @@
# distribution, for details about the copyright.
#

## Compile-time only version for walkDir if you need it at compile-time
## for JavaScript.

type
PathComponent* = enum ## Enumeration specifying a path component.
pcFile, ## path refers to a file
pcLinkToFile, ## path refers to a symbolic link to a file
pcDir, ## path refers to a directory
pcLinkToDir ## path refers to a symbolic link to a directory

proc staticWalkDir(dir: string; relative: bool): seq[
tuple[kind: PathComponent; path: string]] =
discard

iterator walkDir*(dir: string; relative = false): tuple[kind: PathComponent;
path: string] =
for k, v in items(staticWalkDir(dir, relative)):
yield (k, v)

iterator walkDirRec*(dir: string; filter = {pcFile, pcDir}): string =
var stack = @[dir]
while stack.len > 0:
for k, p in walkDir(stack.pop()):
if k in filter:
case k
of pcFile, pcLinkToFile: yield p
of pcDir, pcLinkToDir: stack.add(p)
## This module is deprecated, ``import os`` instead.
{.deprecated: "import os.nim instead".}
import os
export PathComponent, walkDir, walkDirRec