stdspansion/osextras

    Dark Mode
Search:
Group by:

This module, as others in the subpackage do, extends upon the functionality found within the stdlib module of the same name. In this case, it provides some functions focused more upon convienance than anything else.

Types

DirTuple = tuple[dir: string, checkDir: bool]

Procs

proc removeDirs(dirs: openArray[string]; checkDir = false) {...}{.inline,
    raises: [OSError], tags: [WriteDirEffect, ReadDirEffect].}
Remove all directories dir including all subdirectories and files contained within each. A wrapper around stdlib's std/os.removeDir() and a for loop.
proc removeDirs(dirs: openArray[DirTuple]) {...}{.inline, raises: [OSError],
    tags: [WriteDirEffect, ReadDirEffect].}
Alternative to the other removeDirs defined in this module. This version allows for each dir to have its own checkDir valure.
proc empty_dir(dir: string; preserveTree = false; verbose = false;
               checkdir = false): bool {...}{.discardable, raises: [OSError],
    tags: [ReadDirEffect, WriteDirEffect].}

Recursively walk through dir and delete all files and folders within.

Returns false if either nothing was deleted or dir does not exist (see checkdir), otherwise returns true.

If preserveTree is true, then do not delete the directories within. If verbose is true, explain what files/directories are being deleted. If checkdir is true, raise OSError if dir does not exist.