fs.real_path
fs.real_path
Function
Returns the true absolute path as resolved by the operating system, which can be used to eliminate ., .. and resolve symbolic links or Windows junctions.
Syntax
fs(path).real_path()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| String | The real absolute path after parsing. Windows returns the plain drive letter or UNC path text without the \\?\ prefix. |
Example
project = fs('@/src/..').real_path() // Output: the actual absolute path of the project root print project
Notes
- The target path must exist; a Chinese error will be thrown when the path does not exist, has no permission to access, or cannot be parsed by the operating system.
- Symbolic links and Windows junctions resolve to the actual target, so security boundary judgments should compare to the real path rather than the raw text.
- The delimiter of the return value follows the current operating system.