Functions -
filepath
absolute |
Retrieves the absolute path from the provided location.
|
build |
Joins any number of path elements into a single path.
|
extension |
Retrieves the extension of the file path.
|
filename |
Retrieves the base name of the file from the provided location,
which is the last element of the path.
|
getPathListSeparator |
Returns the path variable's separating character for paths of the underlying operating system.
|
getPathSeparator |
Returns the path separator of the underlying operating system.
|
isAbsolute |
Reports whether the path is absolute.
|
isReservedName |
Reports whether the filename is reserved.
|
matches |
Reports whether the complete filename (not just a substring of it) matches the provided Glob pattern.
|
normalize |
Returns the shortest path name equivalent to the given path.
|
parent |
Returns the enclosing parent directory.
|
relative |
Returns a relative path, which is logically equivalent to the target path when joined to the base path with an
intervening separator.
|
resolve |
Returns the filepath after the evaluation of any symbolic links.
|
split |
Splits a list of paths joined by the OS-specific path separator.
|
string|filepath:Error absolutePath = filepath:absolute(<@untainted> "test.txt");
Parameters
- path string
-
String value of the file path free from potential malicious codes
-
Return Type
(string | Error) The absolute path reference or else a
filepath:Error
if the path cannot be derived
string|filepath:Error path = filepath:build("/", "foo", "bar");
Parameters
- parts string[]
-
String values of the file path parts
-
Return Type
(string | Error) String value of the file path or else a
filepath:Error
if the parts are invalid
string|filepath:Error extension = filepath:extension("path.bal");
Parameters
- path string
-
String value of the file path
-
Return Type
(string | Error) The extension of the file, an empty string if there is no extension, or else a
filepath:Error
if the path is invalid
string|filepath:Error name = filepath:filename("/A/B/C.txt");
Parameters
- path string
-
String value of file path
-
Return Type
(string | Error) The name of the file or else a
filepath:Error
if the path is invalid
string pathListSeparator = filepath:getPathListSeparator();
-
Return Type
(string) String value of the path list separator
string pathSeparator = filepath:getPathSeparator();
-
Return Type
(string) String value of the path separator
boolean|filepath:Error isAbsolute = filepath:isAbsolute("/A/B/C");
Parameters
- path string
-
String value of the file path
-
Return Type
(boolean | Error) true
if path is absolute,false
otherwise, or else anfilepath:Error
occurred if the path is invalid
boolean|filepath:Error path = filepath:isReservedName("abc.txt");
Parameters
- name string
-
Filename
-
Return Type
(boolean) True if the path is a Windows reserved name or else false otherwise
boolean|filepath:Error matches = filepath:matches("a/b/c.java", "glob:*.{java,class}");
Parameters
- path string
-
String value of the file path
- pattern string
-
String value of the target file path
-
Return Type
(boolean | Error) true
if the filename of the path matches with the pattern,false
otherwise, or else anfilepath:Error
if the path or pattern is invalid
string|filepath:Error normalizedPath = filepath:normalize("foo/../bar");
Parameters
- path string
-
String value of the file path
-
Return Type
(string | Error) Normalized file path or else a
filepath:Error
if the path is invalid
string|filepath:Error parentPath = filepath:parent("/A/B/C.txt");
Parameters
- path string
-
String value of the file/directory path
-
Return Type
(string | Error) Path of the parent directory or else a
filepath:Error
if an error occurred while getting the parent directory
string|filepath:Error relativePath = filepath:relative("a/b/c", "a/c/d");
Parameters
- base string
-
String value of the base file path
- target string
-
String value of the target file path
-
Return Type
(string | Error) The extension of the file, empty string otherwise, or else an
filepath:Error
occurred if at least one path is invalid
string|filepath:Error resolvedPath = filepath:resolve("a/b/c");
Parameters
- path string
-
Security-validated string value of the file path
-
Return Type
(string | Error) Resolved file path or else a
filepath:Error
if the path is invalid
string[]|filepath:Error parts = filepath:split("/A/B/C");
Parameters
- path string
-
String value of the file path
-
Return Type
(string[] | Error) String array of the part components or else a
filepath:Error
if the path is invalid