feat: add File.realPath() to resolve symlinks and normalize paths

Implement a new static method `File.realPath(path)` that resolves the given path by traversing symlinks and removing redundant `./` and `../` components, returning the canonical absolute path. The implementation uses libuv's `uv_fs_realpath` via an asynchronous callback pattern consistent with other File operations. Includes documentation, foreign method declarations, and two error-case tests for nonexistent paths and wrong argument types.
This commit is contained in:
Bob Nystrom
2016-02-27 23:53:02 +00:00
parent 7265935df4
commit bbafbfd50a
7 changed files with 55 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
import "io" for File
File.realPath("nonexistent") // expect runtime error: no such file or directory
@@ -0,0 +1,6 @@
import "io" for File
File.realPath(123) // expect runtime error: Path must be a string.
// TODO: Write success case tests too when we have an API to create symlinks
// from Wren.