Last active
August 29, 2015 14:14
-
-
Save lizmat/c68fda121ea7078e52cc to your computer and use it in GitHub Desktop.
diff so far
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/io/fileops.c b/src/io/fileops.c | |
index 309d1be..873ca8c 100644 | |
--- a/src/io/fileops.c | |
+++ b/src/io/fileops.c | |
@@ -440,3 +440,14 @@ void MVM_file_symlink(MVMThreadContext *tc, MVMString *oldpath, MVMString *newpa | |
MVM_free(oldpath_s); | |
MVM_free(newpath_s); | |
} | |
+ | |
+MVMString * MVM_file_readlink(MVMThreadContext *tc, MVMString *path) { | |
+ uv_fs_t req; | |
+ char * const path_s = MVM_string_utf8_encode_C_string(tc, path); | |
+ int pathlen = uv_fs_readlink(tc->loop, &req, path_s, NULL); | |
+ MVM_free(path_s); | |
+ if (pathlen) { | |
+ return MVM_string_utf8_decode(tc, tc->instance->VMString, req.ptr, pathlen); | |
+ } | |
+ MVM_exception_throw_adhoc(tc, "Failed to readlink file: %s", uv_strerror(req.result)); | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment