Module pl.path
Path manipulation and file queries.
This is modelled after Python’s os.path library (10.1); see the Guide.
Functions
isdir (P) | is this a directory? |
isfile (P) | is this a file?. |
getsize (P) | return size of a file. |
exists (P) | does a path exist?. |
getatime (P) | Return the time of last access as the number of seconds since the epoch. |
getmtime (P) | Return the time of last modification |
getctime (P) | Return the system’s ctime. |
splitpath (P) | given a path, return the directory part and a file part. |
abspath (P[, pwd]) | return an absolute path. |
splitext (P) | given a path, return the root part and the extension part. |
dirname (P) | return the directory part of a path |
basename (P) | return the file part of a path |
extension (P) | get the extension part of a path. |
isabs (P) | is this an absolute path?. |
join (p1, p2, ...) | return the path resulting from combining the individual paths. |
normcase (P) | normalize the case of a pathname. |
normpath (P) | normalize a path name. |
relpath (P[, start]) | relative path from current directory or optional start point |
expanduser (P) | Replace a starting ‘~’ with the user’s home directory. |
tmpname () | Return a suitable full path to a new temporary file name. |
common_prefix (path1, path2) | return the largest common prefix path of two paths. |
package_path (mod) | return the full path where a particular Lua module would be found. |
Fields
dir | Lua iterator over the entries of a given directory. |
mkdir | Creates a directory. |
rmdir | Removes a directory. |
currentdir | Get the working directory. |
chdir | Changes the working directory. |
is_windows | are we running Windows? |
sep | path separator for this platform. |
dirsep | separator for PATH for this platform |
Functions
- isdir (P)
-
is this a directory?
Parameters:
- P string A file path
- isfile (P)
-
is this a file?.
Parameters:
- P string A file path
- getsize (P)
-
return size of a file.
Parameters:
- P string A file path
- exists (P)
-
does a path exist?.
Parameters:
- P string A file path
Returns:
-
the file path if it exists, nil otherwise
- getatime (P)
-
Return the time of last access as the number of seconds since the epoch.
Parameters:
- P string A file path
- getmtime (P)
-
Return the time of last modification
Parameters:
- P string A file path
- getctime (P)
-
Return the system’s ctime.
Parameters:
- P string A file path
- splitpath (P)
-
given a path, return the directory part and a file part.
if there’s no directory part, the first value will be empty
Parameters:
- P string A file path
- abspath (P[, pwd])
-
return an absolute path.
Parameters:
- splitext (P)
-
given a path, return the root part and the extension part.
if there’s no extension part, the second value will be empty
Parameters:
- P string A file path
Returns:
- dirname (P)
-
return the directory part of a path
Parameters:
- P string A file path
- basename (P)
-
return the file part of a path
Parameters:
- P string A file path
- extension (P)
-
get the extension part of a path.
Parameters:
- P string A file path
- isabs (P)
-
is this an absolute path?.
Parameters:
- P string A file path
- join (p1, p2, ...)
-
return the path resulting from combining the individual paths.
if the second (or later) path is absolute, we return the last absolute path (joined with any non-absolute paths following).
empty elements (except the last) will be ignored.
Parameters:
- normcase (P)
-
normalize the case of a pathname. On Unix, this returns the path unchanged;
for Windows, it converts the path to lowercase, and it also converts forward slashes
to backward slashes.
Parameters:
- P string A file path
- normpath (P)
-
normalize a path name.
A//B, A/./B and A/foo/../B all become A/B.
Parameters:
- P string a file path
- relpath (P[, start])
-
relative path from current directory or optional start point
Parameters:
- expanduser (P)
-
Replace a starting ‘~’ with the user’s home directory.
In windows, if HOME isn’t set, then USERPROFILE is used in preference to
HOMEDRIVE HOMEPATH. This is guaranteed to be writeable on all versions of Windows.
Parameters:
- P string A file path
- tmpname ()
- Return a suitable full path to a new temporary file name. unlike os.tmpnam(), it always gives you a writeable path (uses TEMP environment variable on Windows)
- common_prefix (path1, path2)
-
return the largest common prefix path of two paths.
Parameters:
- package_path (mod)
-
return the full path where a particular Lua module would be found.
Both package.path and package.cpath is searched, so the result may
either be a Lua file or a shared library.
Parameters:
- mod string name of the module
Returns:
- on success: path of module, lua or binary
- on error: nil,error string
Fields
- dir
- Lua iterator over the entries of a given directory. Behaves like lfs.dir
- mkdir
- Creates a directory.
- rmdir
- Removes a directory.
- currentdir
- Get the working directory.
- chdir
- Changes the working directory.
- is_windows
- are we running Windows?
- sep
- path separator for this platform.
- dirsep
- separator for PATH for this platform