Skip to content

realpath is not portable to windows for NODERAWFS #17829

@rchiodo

Description

@rchiodo

Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.19 (a5f7b1c)
clang version 16.0.0 (https://github.com/llvm/llvm-project 30171e76f0e5ea8037bc4d1450dd3e12af4d9938)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/rich/source/emsdk/upstream/bin

Building this c program:

#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

int main(int argc, char *argv[])
{
    struct dirent *pDirent;
    DIR *pDir;

    // Ensure correct argument count.

    if (argc != 2)
    {
        printf("Usage: main <dirname>\n");
        return 1;
    }

    // Get the realpath
    char cresolved_path[PATH_MAX];
    char * res = realpath(argv[1], cresolved_path);
    if (res == NULL) {
        char error_buf[300] = {0};
        strcpy(error_buf, strerror(errno));
        printf("Cannot real path the directory '%s' with '%s'\n", argv[1], error_buf);
        return -1;
    }

    return 0;
}

With -s NODERAWFS should generate a portable js/wasm combination.

It works fine on linux.

When I run this outputted wasm using node on windows, I get this:

PS C:\Users\aku91\source\repos\debugpyweb> node ..\realpath_c\main.js C:\Users\aku91\source\repos
Cannot real path the directory 'C:\Users\aku91\source\repos' with 'No such file or directory'

I think the problem lies in the realpath implementation. It doesn't look like it would work on windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions