HTT Documentation

htt.fs

  • Tftype
    Fields
    • label: string
      • string representation of enum value
  • ADirIterator

    An iterator function returning pairs of path and 'file' type

    An iterator function which, when called, returns a pair of values until such time as there are no more values.

    The path value is the file-system path to the entry (file or directory) and the ftype value is an enumeration type describing the actual type of the entry, notably whether a file or directory.

    Definition
    fun(): path, htt.fs.ftype
  • Apath

    A string representing some file system path.

    Note that the actual path separator string can be gotten with htt.fs.sep.

    Definition
    string
  • Fncwd() → htt.fs.Dir

    Return handle to directory at current working directory (CWD).

    Returns
    • dir: htt.fs.Dir
      • handle to current working directory
  • Csep

    The string used for path separation on this platform.

    Type
    string
  • Fnpath(path) → path

    Convert `path` from using '/' to using the OS-dependent path separator.

    Parameters
    • path: path
      • file-system path with '/' used as path separator
    Returns
    • path
      • path converted to using OS-dependent path separator
  • Fnpath_join(string) → path

    Joins a series of path components into a path using the OS-specific path separator

    Parameters
    • ...: string
      • path components
    Returns
    • path
      • joined path
  • Fndirname(path) → path

    Given a path, strips last component from path and returns it

    If path is the root directory, returns the empty string.

    Parameters
    • path: path
      • file-system path string
    Returns
    • path
      • path to parent directory
  • Fnbasename(path) → string

    Returns the last component of a file path, excluding trailing separators.

    Returns empty string if applied to root path or root of drive.

    Parameters
    • path: path
      • file-system path string
    Returns
    • string
      • name of last component in path
  • Fnnull_file() → path

    Returns the OS-specific 'null' file, such as /dev/null for POSIX-compliant systems.

    Returns
    • path
      • path to null file
  • TDir
    Methods
    • Fnpath() → path?

      Get canonical absolute path to this directory.

      Returns
      • path?
        • path on success, nil otherwise
    • Fnmake_path(path) → nil, string?

      Iteratively creates directory at every level of the provided sub path.

      Returns success if path already exists and is a directory.

      Parameters
      • subpath: path
        • path of dirs, relative to dir, to create
      Returns
      • nil
        • always nil
      • string?
        • error message, if error
    • Fnopen_dir(string) → htt.fs.Dir, string?

      Open directory at `subpath`.

      Parameters
      • subpath: string
        • path relative to dir of directory to open
      Returns
      • directory: htt.fs.Dir
        • handle to the opened directory
      • error: string?
        • error message, if any
    • Fnparent() → htt.fs.Dir, string?

      Open parent directory.

      Returns
      • directory: htt.fs.Dir
        • handle to the opened directory
      • error: string?
        • error message, if any
    • Fnlist() → htt.fs.DirIterator, string?

      Return iterator to loop over all items in directory.

      Returns
      • it: htt.fs.DirIterator
        • iterator for iterating over all items in directory
      • error: string?
        • error message, if any
    • Fnwalk() → htt.fs.DirIterator, string?

      Return iterator for recursively iterating through all contents nested under dir.

      Returns
      • it: htt.fs.DirIterator
        • iterator for recursively iterate over a directory
      • error: string?
        • error message, if any
    • Fnremove(string?) → nil, string?

      Remove item at subpath (or directory itself).

      For directories, this will recursively remove the directory itself and all its contents.

      Parameters
      • subpath: string?
        • (optional) a path relative to this directory. Otherwise this directory.
      Returns
      • nil
        • unused
      • error: string?
        • error message, if any
    • Fnexists(string?) → boolean, string?

      Return true if item at subpath, relative to directory, exists.

      Parameters
      • subpath: string?
        • (optional) either check subpath relative to directory, or directory itself
      Returns
      • boolean
        • true if an item at subpath exists
      • error: string?
        • error message, if any
    • Fntouch(string) → nil, string?

      Create file at subpath, relative to directory.

      Parameters
      • subpath: string
        • path of file to create, relative to directory
      Returns
      • nil
        • unused
      • error: string?
        • error message, if any