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:
@@ -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.
|
||||
Reference in New Issue
Block a user