Module luarocks.fs_win32

Windows implementation of filesystem and platform abstractions. Download http://unxutils.sourceforge.net/ for Windows GNU utilities used by this module.

Functions

absolute_name (pathname, relative_to) Return an absolute pathname from a potentially relative one.
absolute_path (path) Convert a relative path to an absolute one.
base_name (pathname) Strip the path off a path+filename.
change_dir (dir) Change the current directory.
change_dir_to_root () Change directory to root.
copy (src, dest) Copy a file.
current_dir () Obtain current directory.
delete (arg) Delete a file or a directory and all its contents.
dir (at) List the contents of a directory.
dir_name (pathname) Strip the name off a path+filename.
download (url, filename) Download a remote file.
execute (command, ...) Run the given command, quoting its arguments.
exists (file) Test for existance of a file.
find (at) Recursively scan the contents of a directory.
is_dir (file) Test is pathname is a directory.
make_dir (dir) Create a directory if it does not already exist.
make_path (...) Describe a path in a cross-platform way.
make_temp_dir (name) Create a temporary directory.
move (src, dest) Move a file from one location to another
pop_dir () Change working directory to the previous in the dir stack.
remove_dir_if_empty (dir) Remove a directory if it is empty.
split_url (url) Split protocol and path from an URL or local pathname.
unpack_archive (archive) Unpack an archive.
unzip (zipfile) Uncompress files from a .zip archive.
wrap_script (file, dest) Create a wrapper to make a script executable from the command-line.
zip (zipfile, ...) Compress files in a .zip archive.


Functions

absolute_name (pathname, relative_to)
Return an absolute pathname from a potentially relative one.

Parameters

  • pathname: string: pathname to convert.
  • relative_to: string or nil: path to prepend when making pathname absolute, or the current dir in the dir stack if not given.

Return value:

string: The pathname converted to absolute.
absolute_path (path)
Convert a relative path to an absolute one. If a relative path is given, make it absolute relative to the current directory. If an absolute path is given, don't touch it.

Parameters

  • path:

Return value:

string: An absolute path.
base_name (pathname)
Strip the path off a path+filename.

Parameters

  • pathname: string: A path+name, such as "/a/b/c".

Return value:

string: The filename without its path, such as "c".
change_dir (dir)
Change the current directory. Uses the module's internal dir stack. This does not have exact semantics of chdir, as it does not handle errors the same way, but works well for our purposes for now.

Parameters

  • dir: string: The directory to switch to.
change_dir_to_root ()
Change directory to root. Allows leaving a directory (e.g. for deleting it) in a crossplatform way.
copy (src, dest)
Copy a file.

Parameters

  • src: string: Pathname of source
  • dest: string: Pathname of destination

Return value:

boolean: true on success, false on failure.
current_dir ()
Obtain current directory. Uses the module's internal dir stack.

Return value:

string: the absolute path of the current directory.
delete (arg)
Delete a file or a directory and all its contents. For safety, this only accepts absolute paths.

Parameters

  • arg: string: Pathname of source

Return value:

boolean: true on success, false on failure.
dir (at)
List the contents of a directory.

Parameters

  • at: string or nil: directory to list (will be the current directory if none is given).

Return value:

table: an array of strings with the filenames representing the contents of a directory.
dir_name (pathname)
Strip the name off a path+filename.

Parameters

  • pathname: string: A path+name, such as "/a/b/c".

Return value:

string: The filename without its path, such as "/a/b/". For entries such as "/a/b/", "/a/" is returned. If there are no directory separators in input, "" is returned.
download (url, filename)
Download a remote file.

Parameters

  • url: string: URL to be fetched.
  • filename: string or nil: this function attempts to detect the resulting local filename of the remote file as the basename of the URL; if that is not correct (due to a redirection, for example), the local filename can be given explicitly as this second argument.

Return value:

boolean: true on success, false on failure.
execute (command, ...)
Run the given command, quoting its arguments. The command is executed in the current directory in the dir stack.

Parameters

  • command: string: The command to be executed. No quoting/escaping is applied.
  • ...: Strings containing additional arguments, which are quoted.

Return value:

boolean: true if command succeeds (status code 0), false otherwise.
exists (file)
Test for existance of a file.

Parameters

  • file: string: filename to test

Return value:

boolean: true if file exists, false otherwise.
find (at)
Recursively scan the contents of a directory.

Parameters

  • at: string or nil: directory to scan (will be the current directory if none is given).

Return value:

table: an array of strings with the filenames representing the contents of a directory. Paths are returned with forward slashes.
is_dir (file)
Test is pathname is a directory.

Parameters

  • file: string: pathname to test

Return value:

boolean: true if it is a directory, false otherwise.
make_dir (dir)
Create a directory if it does not already exist. If any of the higher levels in the path name does not exist too, they are created as well.

Parameters

  • dir: string: pathname of directory to create.

Return value:

boolean: true on success, false on failure.
make_path (...)
Describe a path in a cross-platform way. Use this function to avoid platform-specific directory separators in other modules. If the first item contains a protocol descriptor (e.g. "http:"), paths are always constituted with forward slashes.

Parameters

  • ...: strings representing directories

Return value:

string: a string with a platform-specific representation of the path.
make_temp_dir (name)
Create a temporary directory.

Parameters

  • name: string: name pattern to use for avoiding conflicts when creating temporary directory.

Return value:

string or nil: name of temporary directory or nil on failure.
move (src, dest)
Move a file from one location to another

Parameters

  • src: string: Pathname of source
  • dest: string: Pathname of destination

Return value:

boolean: true on success, false on failure.
pop_dir ()
Change working directory to the previous in the dir stack.
remove_dir_if_empty (dir)
Remove a directory if it is empty. Does not return errors (for example, if directory is not empty or if already does not exist)

Parameters

  • dir: string: pathname of directory to remove.
split_url (url)
Split protocol and path from an URL or local pathname. URLs should be in the "protocol://path" format. For local pathnames, "file" is returned as the protocol.

Parameters

  • url: string: an URL or a local pathname.

Return value:

string, string: the protocol, and the pathname without the protocol.
unpack_archive (archive)
Unpack an archive. Extract the contents of an archive, detecting its format by filename extension.

Parameters

  • archive: string: Filename of archive.

Return value:

boolean or (boolean, string): true on success, false and an error message on failure.
unzip (zipfile)
Uncompress files from a .zip archive.

Parameters

  • zipfile: string: pathname of .zip archive to be extracted.

Return value:

boolean: true on success, false on failure.
wrap_script (file, dest)
Create a wrapper to make a script executable from the command-line.

Parameters

  • file: string: Pathname of script to be made executable.
  • dest: string: Directory where to put the wrapper.

Return value:

boolean or (nil, string): True if succeeded, or nil and an error message.
zip (zipfile, ...)
Compress files in a .zip archive.

Parameters

  • zipfile: string: pathname of .zip archive to be created.
  • ...: Filenames to be stored in the archive are given as additional arguments.

Return value:

boolean: true on success, false on failure.

Valid XHTML 1.0!