Module file

Simple file operations.

This module provides actions to handle simple filesystem operations.

Info:

  • Copyright: 2011-2015 Chad Phillips
  • Author: Chad Phillips

Actions

create_directory Creates a directory.
delete_file Delete a file.
file_exists Determines if a file exists in the filesystem.
file_size Checks a file's size.
move_file Move a file from one location to another.
remove_directory Removes a directory.

Handlers

filesystem The filesystem handler (default).


Actions

create_directory
Creates a directory.

This action creates a directory on the filesystem in the specified location.

  • action string create_directory
  • directory string The directory to create, including the path. Provide either the full path or a relative path from the FreeSWITCH 'base_dir' global variable.
  • handler string The handler to use, see handlers. If not specified, defaults to the default handler for the module.

Usage:

    {
      action = "create_directory",
      directory = "/tmp/mynewdir",
    }
delete_file
Delete a file.

This action deletes a file from a location on the filesystem.

  • action string delete_file
  • file string The file to delete, including the path. Provide either the full path or a relative path from the FreeSWITCH 'base_dir' global variable.
  • handler string The handler to use, see handlers. If not specified, defaults to the default handler for the module.

Usage:

    {
      action = "delete_file",
      file = "/tmp/afile.txt",
    }
file_exists
Determines if a file exists in the filesystem.

This action determines if a file exists on the filesystem. This only checks for basic existence -- the file must be readable by the FreeSWITCH user.

The action will store the result of its check in the 'file' storage area, key 'file_exists': 'true' if the file exists, 'false' otherwise.

  • action string file_exists
  • file string The file to check, including the path. Provide either the full path or a relative path from the FreeSWITCH 'base_dir' global variable.
  • if_false string (Optional) The sequence to call if the file does not exist.
  • if_true string (Optional) The sequence to call if the file exists.
  • handler string The handler to use, see handlers. If not specified, defaults to the default handler for the module.

Usage:

    {
      action = "file_exists",
      file = "/tmp/afile.txt",
      if_false = "do_this",
      if_true = "do_that",
    }
file_size
Checks a file's size.

This action checks the size of a file. The result is stored in the 'file' storage area, key 'size'.

  • action string file_size
  • file string The file to check, including the path. Provide either the full path or a relative path from the FreeSWITCH 'base_dir' global variable.
  • handler string The handler to use, see handlers. If not specified, defaults to the default handler for the module.

Usage:

    {
      action = "file_size",
      file = "/tmp/afile.txt",
    }
move_file
Move a file from one location to another.

This action moves a file from one location on the filesystem to another.

  • action string move_file
  • binary bool (Optional) Boolean, only neccesary for copying files. Set to true if the source file is binary (sound files are typically binary). Default is false.
  • copy bool (Optional) To copy the file to the destination instead of moving it, set this to true. Default is false.
  • destination string The new destination of the file, including the path. Provide either the full path or a relative path from the FreeSWITCH 'base_dir' global variable.
  • source string The file to move, including the path. Provide either the full path or a relative path from the FreeSWITCH 'base_dir' global variable.
  • handler string The handler to use, see handlers. If not specified, defaults to the default handler for the module.

Usage:

    {
      action = "move_file",
      binary = false,
      copy = false,
      destination = "storage/mymovedfile.txt",
      source = "/tmp/originalfile.txt",
    }
remove_directory
Removes a directory.

This action removes a directory from the filesystem in the specified location.

  • action string remove_directory
  • directory string The directory to remove, including the path. Provide either the full path or a relative path from the FreeSWITCH 'base_dir' global variable.
  • handler string The handler to use, see handlers. If not specified, defaults to the default handler for the module.

Usage:

    {
      action = "remove_directory",
      directory = "/tmp/somedir",
    }

Handlers

filesystem
The filesystem handler (default).

The default handler for the file module. This handles file operations on the local filesystem.

Usage:

    {
      action = "create_directory",
      handler = "filesystem",
      -- other params...
    }
generated by LDoc 1.4.6 Last updated 2021-04-08 08:59:59