Module pl.path

Path manipulation and file queries.

This is modelled after Python's os.path library (11.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) 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 P resulting from combining the two paths.
normcase (P) normalize the case of a pathname.
normpath (P) normalize a path name.
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

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: A file path
isfile (P)
is this a file?.

Parameters:

  • P: A file path
getsize (P)
return size of a file.

Parameters:

  • P: A file path
exists (P)
does a path exist?.

Parameters:

  • P: 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: A file path
getmtime (P)
Return the time of last modification

Parameters:

  • P: A file path
getctime (P)
Return the system's ctime.

Parameters:

  • P: 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: A file path
abspath (P)
return an absolute path.

Parameters:

  • P: A file path
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: A file path
dirname (P)
return the directory part of a path

Parameters:

  • P: A file path
basename (P)
return the file part of a path

Parameters:

  • P: A file path
extension (P)
get the extension part of a path.

Parameters:

  • P: A file path
isabs (P)
is this an absolute path?.

Parameters:

  • P: A file path
join (p1, p2)
return the P 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 (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: A file path
normpath (P)
normalize a path name. A//B, A/./B and A/foo/../B all become A/B.

Parameters:

  • P: a file path
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: 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)
common_prefix (path1, path2)
return the largest common prefix path of two paths.

Parameters:

  • path1: a file path
  • path2: 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

Returns:

  1. on success: path of module, lua or binary
  2. on error: nil,error string

Fields

is_windows
are we running Windows?
sep
path separator for this platform.
dirsep
separator for PATH for this platform
generated by LDoc 1.2