1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-20 15:44:49 +00:00

Merge pull request #420 from leafgarland/master

Implement os/realpath with _fullpath
This commit is contained in:
Calvin Rose 2020-06-02 20:57:28 -04:00 committed by GitHub
commit 6c08dbab0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 10 deletions

View File

@ -1224,17 +1224,16 @@ static Janet os_rename(int32_t argc, Janet *argv) {
static Janet os_realpath(int32_t argc, Janet *argv) {
janet_fixarity(argc, 1);
#ifdef JANET_NO_REALPATH
(void) argv;
janet_panic("os/realpath not supported on this platform");
#else
const char *src = janet_getcstring(argv, 0);
#ifdef JANET_WINDOWS
char *dest = _fullpath(NULL, src, _MAX_PATH);
#else
char *dest = realpath(src, NULL);
#endif
if (NULL == dest) janet_panicf("%s: %s", strerror(errno), src);
Janet ret = janet_cstringv(dest);
free(dest);
return ret;
#endif
}
static Janet os_permission_string(int32_t argc, Janet *argv) {

View File

@ -138,11 +138,6 @@ extern "C" {
#define JANET_NO_UTC_MKTIME
#endif
/* Add some windows flags */
#ifdef JANET_WINDOWS
#define JANET_NO_REALPATH
#endif
/* Define how global janet state is declared */
#ifdef JANET_SINGLE_THREADED
#define JANET_THREAD_LOCAL