fs.q

The filesystem: .fs.exists, .fs.isfile, .fs.isdir, .fs.size answer for a path, a symbol or a list of them; .fs.remove deletes the files named and .fs.rmdir the empty directories named - never anything below them; .fs.rmtree deletes a directory tree. .fs.walk lists a tree's files, .fs.gettempdir names the temporary directory and .fs.mkdtemp makes a new one in it.
  • implNote - Every path argument converts through .path.path, so .fs takes a string, a symbol or a path and inherits .path's refusal of `:pq: provider handles and scheme:// URLs. The names are Python's os/shutil/tempfile spellings. .fs.remove and .fs.rmdir are one hdel per element, and hdel's refusal of a populated directory is their whole guard; .fs.rmtree is the ONE recursive delete, and native, because a q walk over `key` follows links.

Entity Summary

EntitiesShort Description
.fs.exists[p]whether the path names anything at all, file or directory.
.fs.gettempdir[]the directory temporary files belong in: the first of the TMPDIR, TEMP and TMP environment variables that is set and not empty, else "/tmp".
.fs.isdir[p]whether the path names a directory - an EMPTY one still is one.
.fs.isfile[p]whether the path names a regular file.
.fs.mkdtemp[]a new, empty directory under .fs.gettempdir[], its path as a string.
.fs.remove[p]delete ONE file.
.fs.rmdir[p]delete ONE EMPTY directory.
.fs.rmtree[p]delete a directory and everything in it, answering its path; a link inside it, or named, is removed and never followed.
.fs.size[p]the file's size in bytes.
.fs.walk[p;pattern]the files at any depth under a directory whose names match a `like` pattern, as strings relative to it, in `key` order.

Entity Details

.fs.exists[p]

whether the path names anything at all, file or directory.

Parameters:
  • p - (any) a path, a string or a symbol - or a list of them

.fs.isdir[p]

whether the path names a directory - an EMPTY one still is one.

Parameters:
  • p - (any) a path, a string or a symbol - or a list of them

.fs.isfile[p]

whether the path names a regular file.

Parameters:
  • p - (any) a path, a string or a symbol - or a list of them

.fs.remove[p]

delete ONE file. A directory is 'domain whether it is empty or not: remove is the file verb, and letting hdel answer would quietly delete an empty directory. A missing path is hdel's own 'io.

Parameters:
  • p - (any) a path, a string or a symbol - or a list of them

.fs.rmdir[p]

delete ONE EMPTY directory. A file is 'domain: rmdir is the directory verb. A POPULATED directory is hdel's own 'io and survives intact - the engine's refusal to recurse is the guard, and it is passed through untouched.

Parameters:
  • p - (any) a path, a string or a symbol - or a list of them

.fs.rmtree[p]

delete a directory and everything in it, answering its path; a link inside it, or named, is removed and never followed. A file, a root, the working directory or any directory above it is 'domain; a missing path is 'io.

Parameters:
  • p - (any) a path, a string or a symbol - or a list of them

.fs.size[p]

the file's size in bytes. A directory is NOT refused and does NOT answer the size of its contents - hcount hands back the OS's own directory-entry size, exactly as Python's os.path.getsize does. A missing path is 'io.

Parameters:
  • p - (any) a path, a string or a symbol - or a list of them

.fs.walk[p;pattern]

the files at any depth under a directory whose names match a `like` pattern, as strings relative to it, in `key` order. A file answers its own name when it matches; an empty directory or a missing path answers ().

Parameters:
  • p - (any) a path, a string or a symbol
  • pattern - (string) a `like` pattern, matched against each file's name