Filesystem path related operations for different platforms.
More...
|
| unassigned | osSeps (string p) |
| | Recompute path configurations for a given gawk platform.
|
| |
| number | isSep (char c) |
| | Check if a character is a path separator.
|
| |
| string | basename (string p) |
| | Get the last component of a pathname.
|
| |
| string | dirname (string p) |
| | Gets the parent directory name of a pathname.
|
| |
| unassigned | splitExt (string p, array< string > R) |
| | Splits a path into its file path and its extension.
|
| |
| string | extension (string p) |
| | Get the extension portion of a pathname.
|
| |
| number | isAbs (string p) |
| | Check whether a pathname is absolute.
|
| |
| number | isRel (string p) |
| | Check whether a pathname is relative.
|
| |
| unassigned | splitDrive (string p, array< string > R) |
| | Split a pathname into its drive and and path components.
|
| |
| number | hasDevice (string p) |
| | Check whether a pathname has a device prefix.
|
| |
| string | root (string p) |
| | Get the root directory of a path.
|
| |
| number | isRootDir (string p) |
| | Check whether a path is the root directory.
|
| |
| number | isCrossValidName (string f) |
| | Check if a filename is valid for cross-platform regular use.
|
| |
| number | isValidName (string f) |
| | Check if a filename is valid for regular use in the current path platform.
|
| |
| string | normcase (string p) |
| | Normalize the casing and separator of a pathname for the current platform.
|
| |
| string | normalize (string p, number keep_f=0, number case_f=1) |
| | Normalize a pathname.
|
| |
|
| string | sep |
| | File path separator.
|
| |
| string | altsep |
| | Alternative file path separator.
|
| |
| string | delim |
| | Search path separator.
|
| |
| string | curdir |
| | Current directory symbol.
|
| |
| string | pardir |
| | Parent directory symbol.
|
| |
| string | extsep |
| | Extension symbol.
|
| |
| string | cased |
| | Whether file system is case sensitive or not.
|
| |
| string | droot |
| | Whether double slash // is a distinct file system root or not.
|
| |
| string | drel |
| | Whether a drive letter can be in a relative path or not.
|
| |
Filesystem path related operations for different platforms.
This module offers functions for querying information on filesystem paths for different platforms (currently Windows and Unix) depending on settable variables. The default path configurations depend on PROCINFO["platform"]
The expected results of many of these functions were considered based on existing path libraries in other languages, preferring the C or C++ way specially in edge cases were they tend to differ.
References:
For future directions:
◆ basename()
| string path::basename |
( |
string | p | ) |
|
Get the last component of a pathname.
- Parameters
-
- Returns
- Last component of the pathname
◆ dirname()
| string path::dirname |
( |
string | p | ) |
|
Gets the parent directory name of a pathname.
- Parameters
-
- Returns
- Parent directory name of the pathname
◆ extension()
| string path::extension |
( |
string | p | ) |
|
Get the extension portion of a pathname.
- Parameters
-
- Returns
- Extension of the pathname
- Note
- Similar to the C++ and NodeJS way of getting the extension, not the Python way
◆ hasDevice()
| number path::hasDevice |
( |
string | p | ) |
|
Check whether a pathname has a device prefix.
- Parameters
-
- Returns
- 1 if the pathname has a device prefix. 0 otherwise
◆ isAbs()
| number path::isAbs |
( |
string | p | ) |
|
Check whether a pathname is absolute.
- Parameters
-
- Returns
- 1 if the pathname is absolute. 0 otherwise
◆ isCrossValidName()
| number path::isCrossValidName |
( |
string | f | ) |
|
Check if a filename is valid for cross-platform regular use.
- Parameters
-
| f | File name. Not a whole path |
- Returns
- 1 if the path is cross-platform valid. 0 otherwise
- Note
- Platforms taken into account are Windows, and POSIX Unix-like systems
- Todo
- maximum length parameter, defaulting to 255 (bytes)
◆ isRel()
| number path::isRel |
( |
string | p | ) |
|
Check whether a pathname is relative.
- Parameters
-
- Returns
- 1 if the pathname is relative. 0 otherwise
◆ isRootDir()
| number path::isRootDir |
( |
string | p | ) |
|
Check whether a path is the root directory.
- Parameters
-
- Returns
- 1 if the path is a root directory for the current platform. 0 otherwise
◆ isSep()
| number path::isSep |
( |
char | c | ) |
|
Check if a character is a path separator.
- Parameters
-
- Returns
- 1 if it is a separator. 0 otherwise
◆ isValidName()
| number path::isValidName |
( |
string | f | ) |
|
Check if a filename is valid for regular use in the current path platform.
- Parameters
-
| f | File name. Not a whole path |
- Returns
- 1 if the path is valid for current platform. 0 otherwise
- Note
- This doesn't consider valid the special directory names like
. or .. on Unix
◆ normalize()
| string path::normalize |
( |
string | p, |
|
|
number | keep_f = 0, |
|
|
number | case_f = 1 ) |
Normalize a pathname.
- Parameters
-
| p | File path name to normalize |
| keep_f | 1 to keep trailing separators |
| case_f | 1 to normalize the case on case-insensitive platforms |
- Returns
- Normalized path. Taking care of
., .. and repeated separators
- Todo
- option to preserve trailing sep
◆ normcase()
| string path::normcase |
( |
string | p | ) |
|
Normalize the casing and separator of a pathname for the current platform.
- Parameters
-
- Returns
- Path name with its casing and separator normalize if applies for the current platform
◆ osSeps()
| unassigned path::osSeps |
( |
string | p | ) |
|
Recompute path configurations for a given gawk platform.
- Parameters
-
| p | Gawk platform as in PROCINFO["platform"] |
- Returns
◆ root()
| string path::root |
( |
string | p | ) |
|
Get the root directory of a path.
- Parameters
-
- Returns
- Root directory for the path
◆ splitDrive()
| unassigned path::splitDrive |
( |
string | p, |
|
|
array< string > | R ) |
Split a pathname into its drive and and path components.
- Parameters
-
| p | File path name |
| [out] | R | Array to fill with:
- Drive label portion
- File path name without its drive label portion
|
- Returns
- Todo
- UNC handling, check Nim's
ntpath/splitDrive
◆ splitExt()
| unassigned path::splitExt |
( |
string | p, |
|
|
array< string > | R ) |
Splits a path into its file path and its extension.
- Parameters
-
| p | File path name |
| [out] | R | Array to fill with:
- File path name without its extension portion
- Extension portion
|
- Returns
◆ altsep
Alternative file path separator.
◆ cased
Whether file system is case sensitive or not.
◆ curdir
Current directory symbol.
◆ delim
◆ drel
Whether a drive letter can be in a relative path or not.
◆ droot
Whether double slash // is a distinct file system root or not.
◆ extsep
◆ pardir
◆ sep