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:
@@ -17,6 +17,7 @@ extern void fileSizePath(WrenVM* vm);
|
||||
extern void fileClose(WrenVM* vm);
|
||||
extern void fileDescriptor(WrenVM* vm);
|
||||
extern void fileReadBytes(WrenVM* vm);
|
||||
extern void fileRealPath(WrenVM* vm);
|
||||
extern void fileSize(WrenVM* vm);
|
||||
extern void fileStat(WrenVM* vm);
|
||||
extern void fileWriteBytes(WrenVM* vm);
|
||||
@@ -115,6 +116,7 @@ static ModuleRegistry modules[] =
|
||||
FINALIZER(fileFinalize)
|
||||
STATIC_METHOD("delete_(_,_)", fileDelete)
|
||||
STATIC_METHOD("open_(_,_,_)", fileOpen)
|
||||
STATIC_METHOD("realPath_(_,_)", fileRealPath)
|
||||
STATIC_METHOD("sizePath_(_,_)", fileSizePath)
|
||||
METHOD("close_(_)", fileClose)
|
||||
METHOD("descriptor", fileDescriptor)
|
||||
|
||||
Reference in New Issue
Block a user