From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- Data/Libraries/Penlight/docs/libraries/pl.dir.html | 615 +++++++++++++++++++++ 1 file changed, 615 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.dir.html (limited to 'Data/Libraries/Penlight/docs/libraries/pl.dir.html') diff --git a/Data/Libraries/Penlight/docs/libraries/pl.dir.html b/Data/Libraries/Penlight/docs/libraries/pl.dir.html new file mode 100644 index 0000000..5dfa0f6 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.dir.html @@ -0,0 +1,615 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.dir

+

Listing files in directories and creating/removing directory paths.

+

Dependencies: pl.utils, pl.path

+ +

Soft Dependencies: alien, ffi (either are used on Windows for copying/moving files)

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fnmatch (filename, pattern)Test whether a file name matches a shell pattern.
filter (filenames, pattern)Return a list of all file names within an array which match a pattern.
getfiles (dirname, mask)return a list of all files in a directory which match a shell pattern.
getdirectories (dirname)return a list of all subdirectories of the directory.
copyfile (src, dest, flag)copy a file.
movefile (src, dest)move a file.
walk (root, bottom_up, follow_links)return an iterator which walks through a directory tree starting at root.
rmtree (fullpath)remove a whole directory tree.
makepath (p)create a directory path.
clonetree (path1, path2, file_fun, verbose)clone a directory tree.
dirtree (d)return an iterator over all entries in a directory tree
getallfiles (start_path, shell_pattern)Recursively returns all the file starting at path.
+ +
+
+ + +

Functions

+ +
+
+ + fnmatch (filename, pattern) +
+
+ Test whether a file name matches a shell pattern. + Both parameters are case-normalized if operating system is + case-insensitive. + + +

Parameters:

+
    +
  • filename + string + A file name. +
  • +
  • pattern + string + A shell pattern. The only special characters are + '*' and '?': '*' matches any sequence of characters and + '?' matches any single character. +
  • +
+ +

Returns:

+
    + + bool + + + +
+ +

Raises:

+ dir and mask must be strings + + + +
+
+ + filter (filenames, pattern) +
+
+ Return a list of all file names within an array which match a pattern. + + +

Parameters:

+
    +
  • filenames + tab + An array containing file names. +
  • +
  • pattern + string + A shell pattern. +
  • +
+ +

Returns:

+
    + + List(string) + List of matching file names. +
+ +

Raises:

+ dir and mask must be strings + + + +
+
+ + getfiles (dirname, mask) +
+
+ return a list of all files in a directory which match a shell pattern. + + +

Parameters:

+
    +
  • dirname + string + A directory. If not given, all files in current directory are returned. +
  • +
  • mask + string + A shell pattern. If not given, all files are returned. +
  • +
+ +

Returns:

+
    + + {string} + list of files +
+ +

Raises:

+ dirname and mask must be strings + + + +
+
+ + getdirectories (dirname) +
+
+ return a list of all subdirectories of the directory. + + +

Parameters:

+
    +
  • dirname + string + A directory +
  • +
+ +

Returns:

+
    + + {string} + a list of directories +
+ +

Raises:

+ dir must be a a valid directory + + + +
+
+ + copyfile (src, dest, flag) +
+
+ copy a file. + + +

Parameters:

+
    +
  • src + string + source file +
  • +
  • dest + string + destination file or directory +
  • +
  • flag + bool + true if you want to force the copy (default) +
  • +
+ +

Returns:

+
    + + bool + operation succeeded +
+ +

Raises:

+ src and dest must be strings + + + +
+
+ + movefile (src, dest) +
+
+ move a file. + + +

Parameters:

+
    +
  • src + string + source file +
  • +
  • dest + string + destination file or directory +
  • +
+ +

Returns:

+
    + + bool + operation succeeded +
+ +

Raises:

+ src and dest must be strings + + + +
+
+ + walk (root, bottom_up, follow_links) +
+
+ return an iterator which walks through a directory tree starting at root. + The iterator returns (root,dirs,files) + Note that dirs and files are lists of names (i.e. you must say path.join(root,d) + to get the actual full path) + If bottom_up is false (or not present), then the entries at the current level are returned + before we go deeper. This means that you can modify the returned list of directories before + continuing. + This is a clone of os.walk from the Python libraries. + + +

Parameters:

+
    +
  • root + string + A starting directory +
  • +
  • bottom_up + bool + False if we start listing entries immediately. +
  • +
  • follow_links + bool + follow symbolic links +
  • +
+ +

Returns:

+
    + + an iterator returning root,dirs,files +
+ +

Raises:

+ root must be a directory + + + +
+
+ + rmtree (fullpath) +
+
+ remove a whole directory tree. + Symlinks in the tree will be deleted without following them. + + +

Parameters:

+
    +
  • fullpath + string + A directory path (must be an actual directory, not a symlink) +
  • +
+ +

Returns:

+
    +
  1. + true or nil
  2. +
  3. + error if failed
  4. +
+ +

Raises:

+ fullpath must be a string + + + +
+
+ + makepath (p) +
+
+ create a directory path. + This will create subdirectories as necessary! + + +

Parameters:

+
    +
  • p + string + A directory path +
  • +
+ +

Returns:

+
    + + true on success, nil + errormsg on failure +
+ +

Raises:

+ failure to create + + + +
+
+ + clonetree (path1, path2, file_fun, verbose) +
+
+ clone a directory tree. Will always try to create a new directory structure + if necessary. + + +

Parameters:

+
    +
  • path1 + string + the base path of the source tree +
  • +
  • path2 + string + the new base path for the destination +
  • +
  • file_fun + func + an optional function to apply on all files +
  • +
  • verbose + bool + an optional boolean to control the verbosity of the output. + It can also be a logging function that behaves like print() +
  • +
+ +

Returns:

+
    +
  1. + true, or nil
  2. +
  3. + error message, or list of failed directory creations
  4. +
  5. + list of failed file operations
  6. +
+ +

Raises:

+ path1 and path2 must be strings + + +

Usage:

+
    +
    clonetree('.','../backup',copyfile)
    +
+ +
+
+ + dirtree (d) +
+
+ return an iterator over all entries in a directory tree + + +

Parameters:

+
    +
  • d + string + a directory +
  • +
+ +

Returns:

+
    + + an iterator giving pathname and mode (true for dir, false otherwise) +
+ +

Raises:

+ d must be a non-empty string + + + +
+
+ + getallfiles (start_path, shell_pattern) +
+
+ Recursively returns all the file starting at path. It can optionally take a shell pattern and + only returns files that match shellpattern_. If a pattern is given it will do a case insensitive search. + + +

Parameters:

+
    +
  • start_path + string + A directory. If not given, all files in current directory are returned. +
  • +
  • shell_pattern + string + A shell pattern. If not given, all files are returned. +
  • +
+ +

Returns:

+
    + + List(string) + containing all the files found recursively starting at path and filtered by shellpattern_. +
+ +

Raises:

+ start_path must be a directory + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0