summary refs log tree commit diff stats
path: root/lib/std/dirs.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-10-25 17:56:11 +0800
committerGitHub <noreply@github.com>2022-10-25 17:56:11 +0800
commit69eaa4f14cdb1276650141adb6b2e96f478e0856 (patch)
treece7bf7046f52abfac2b1ddfddcf6b570674d4a63 /lib/std/dirs.nim
parentdaf35c6d1b4bc1377bf278aa265dab30c9f5867e (diff)
downloadNim-69eaa4f14cdb1276650141adb6b2e96f478e0856.tar.gz
clean up `std/os` related modules (#20651)
* clean up `std/os` related modules

* use `cmpPaths`

* reset

* cleanup
Diffstat (limited to 'lib/std/dirs.nim')
-rw-r--r--lib/std/dirs.nim55
1 files changed, 9 insertions, 46 deletions
diff --git a/lib/std/dirs.nim b/lib/std/dirs.nim
index 304075a6f..770ea9a01 100644
--- a/lib/std/dirs.nim
+++ b/lib/std/dirs.nim
@@ -1,7 +1,7 @@
 from paths import Path, ReadDirEffect, WriteDirEffect
 
 from std/private/osdirs import dirExists, createDir, existsOrCreateDir, removeDir,
-                               moveDir, walkPattern, walkFiles, walkDirs, walkDir,
+                               moveDir, walkDir, setCurrentDir,
                                walkDirRec, PathComponent
 
 export PathComponent
@@ -76,51 +76,6 @@ proc moveDir*(source, dest: Path) {.inline, tags: [ReadIOEffect, WriteIOEffect].
   ## * `createDir proc`_
   moveDir(source.string, dest.string)
 
-iterator walkPattern*(pattern: Path): Path {.tags: [ReadDirEffect].} =
-  ## Iterate over all the files and directories that match the `pattern`.
-  ##
-  ## On POSIX this uses the `glob`:idx: call.
-  ## `pattern` is OS dependent, but at least the `"*.ext"`
-  ## notation is supported.
-  ##
-  ## See also:
-  ## * `walkFiles iterator`_
-  ## * `walkDirs iterator`_
-  ## * `walkDir iterator`_
-  ## * `walkDirRec iterator`_
-  for p in walkPattern(pattern.string):
-    yield Path(p)
-
-iterator walkFiles*(pattern: Path): Path {.tags: [ReadDirEffect].} =
-  ## Iterate over all the files that match the `pattern`.
-  ##
-  ## On POSIX this uses the `glob`:idx: call.
-  ## `pattern` is OS dependent, but at least the `"*.ext"`
-  ## notation is supported.
-  ##
-  ## See also:
-  ## * `walkPattern iterator`_
-  ## * `walkDirs iterator`_
-  ## * `walkDir iterator`_
-  ## * `walkDirRec iterator`_
-  for p in walkFiles(pattern.string):
-    yield Path(p)
-
-iterator walkDirs*(pattern: Path): Path {.tags: [ReadDirEffect].} =
-  ## Iterate over all the directories that match the `pattern`.
-  ##
-  ## On POSIX this uses the `glob`:idx: call.
-  ## `pattern` is OS dependent, but at least the `"*.ext"`
-  ## notation is supported.
-  ##
-  ## See also:
-  ## * `walkPattern iterator`_
-  ## * `walkFiles iterator`_
-  ## * `walkDir iterator`_
-  ## * `walkDirRec iterator`_
-  for p in walkDirs(pattern.string):
-    yield Path(p)
-
 iterator walkDir*(dir: Path; relative = false, checkDir = false,
                  onlyRegular = false):
     tuple[kind: PathComponent, path: Path] {.tags: [ReadDirEffect].} =
@@ -179,3 +134,11 @@ iterator walkDirRec*(dir: Path,
   for p in walkDirRec(dir.string, yieldFilter, followFilter, relative,
                       checkDir, onlyRegular):
     yield Path(p)
+
+proc setCurrentDir*(newDir: Path) {.inline, tags: [].} =
+  ## Sets the `current working directory`:idx:; `OSError`
+  ## is raised if `newDir` cannot been set.
+  ##
+  ## See also:
+  ## * `getCurrentDir proc`_
+  osdirs.setCurrentDir(newDir.string)