fs.real_path

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

Parameters

No parameters.

Return value

TypeDescription
StringThe real absolute path after parsing. Windows returns the plain drive letter or UNC path text without the \\?\ prefix.

Example

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.