Module filesystem

File system and directory operation utilities.

License GPL v3.0

Table of contents

Functions

make_directory(path, cb) Creates a directory at the given path.
iterate_contents(dir, iteratee, options[, cb="standard::type"]) Iterates the contents of a directory.
list_contents(dir, attributes, cb) Lists the contents of a directory.
remove_directory(dir, cb) Recursively removes a directory and its contents.

Functions

make_directory(path, cb) [src]
async
since v0.2.0
Creates a directory at the given path.

This only creates the child directory of the immediate parent of path. If the parent directory doesn’t exist, this operation will fail.

Parameters:

  • path
    type string, File or Gio.File
  • cb
    type function

Callback parameters:

  • type GLib.Error
iterate_contents(dir, iteratee, options[, cb="standard::type"]) [src]
async
since v0.2.0
Iterates the contents of a directory.

The iteratee callback is called once for every entry in the given directory, passing a Gio.FileInfo as argument. It’s callback argument only expects a single error parameter.

If options.recursive == true, iteration will recurse into subdirectories. options.list_directories can be used to have iteratee not be called on directory entries.

On error, either within the iteration or passed by iteratee, iteration is aborted and the final callback is called.

See file:query_info and g_file_query_info for information on the attributes parameter.

Parameters:

  • dir :  The directory to query contents for.
    type string, File or Gio.File
  • iteratee :  The iterator function that will be called for each entry. The function will be called with a Gio.FileInfo and a callback: function(info, cb).
    type function
  • options
    type table
    • attributes :  The attributes to query.
      type string
      default "standard::type"
    • recursive :  Recurse into directories.
      type boolean
      default false
    • list_directories :  If false, directories will not trigger iteratee.
      type boolean
      default true
  • cb
    type function

Callback parameters:

  • type GLib.Error
list_contents(dir, attributes, cb) [src]
async
since v0.2.0
Lists the contents of a directory.

See file:query_info and g_file_query_info for information on the attributes parameter.

Parameters:

  • dir :  The directory to query contents for.
    type string, File or Gio.File
  • attributes :  The attributes to query.
    type string
  • cb
    type function

Callback parameters:

  • type GLib.Error
  • A list of Gio.FileInfos
    type table
remove_directory(dir, cb) [src]
async
since v0.2.0
Recursively removes a directory and its contents.

Parameters:

  • dir :  The directory to remove.
    type string, File or Gio.File
  • cb
    type function

Callback parameters:

  • type GLib.Error