Module pl.path
path manipulation and file queries.
This is modelled after Python's os.path library (11.1)
Functions
abspath (path) | return an absolute path. |
basename (path) | return the file part of a path |
common_prefix (path1, path2) | return the largest common prefix path of two paths. |
dirname (path) | return the directory part of a path |
exists (path) | does a path exist?. |
expanduser (path) | Replace a starting '~' with the user's home directory. |
extension (path) | get the extension part of a path. |
getatime (path) | Return the time of last access as the number of seconds since the epoch. |
getctime (path) | Return the system's ctime. |
getmtime (path) | Return the time of last modification |
getsize (path) | return size of a file. |
isabs (path) | is this an absolute path?. |
isdir (path) | is this a directory? |
isfile (path) | is this a file?. |
join (p1, p2) | return the path resulting from combining the two paths. |
normcase (path) | Normalize the case of a pathname. |
package_path (mod) | return the full path where a particular Lua module would be found. |
splitext (path) | given a path, return the root part and the extension part. |
splitpath (path) | given a path, return the directory part and a file part. |
tmpname () | Return a suitable full path to a new temporary file name. |
Functions
- abspath (path)
-
return an absolute path.
Parameters:
-
path
: A file path
-
- basename (path)
-
return the file part of a path
Parameters:
-
path
: A file path
-
- common_prefix (path1, path2)
-
return the largest common prefix path of two paths.
Parameters:
-
path1
: a file path -
path2
: a file path
-
- dirname (path)
-
return the directory part of a path
Parameters:
-
path
: A file path
-
- exists (path)
-
does a path exist?.
Parameters:
-
path
: A file path
-
- expanduser (path)
-
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:
-
path
: A file path
-
- extension (path)
-
get the extension part of a path.
Parameters:
-
path
: A file path
-
- getatime (path)
-
Return the time of last access as the number of seconds since the epoch.
Parameters:
-
path
: A file path
-
- getctime (path)
-
Return the system's ctime.
Parameters:
-
path
: A file path
-
- getmtime (path)
-
Return the time of last modification
Parameters:
-
path
: A file path
-
- getsize (path)
-
return size of a file.
Parameters:
-
path
: A file path
-
- isabs (path)
-
is this an absolute path?.
Parameters:
-
path
: A file path
-
- isdir (path)
-
is this a directory?
Parameters:
-
path
: A file path
-
- isfile (path)
-
is this a file?.
Parameters:
-
path
: A file path
-
- join (p1, p2)
-
return the path resulting from combining the two paths. if the second is already an absolute path, then it returns it.
Parameters:
-
p1
: A file path -
p2
: A file path
-
- normcase (path)
-
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. Will also replace '\dir\..\' by '\' (PL extension!)
Parameters:
-
path
: A file path
-
- 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 libarary.
Parameters:
-
mod
: name of the module
-
- splitext (path)
-
given a path, return the root part and the extension part. if there's no extension part, the second value will be empty
Parameters:
-
path
: A file path
-
- splitpath (path)
-
given a path, return the directory part and a file part. if there's no directory part, the first value will be empty
Parameters:
-
path
: 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 %TMP% on Windows)