stat() not working

21 views
Skip to first unread message

Mike Moreton

unread,
Oct 5, 2020, 5:10:42 AM10/5/20
to emscripten-discuss
From C++, when I call stat() on a file that doesn't exist, I get success (i.e. 0) rather than failure (i.e. -1).

The stat structure has st_mode set to zero, though I'm not sure if this is the value before the call not being changed, or if it is explicitly zeroed.

Anyone have any ideas?

Sam Clegg

unread,
Oct 5, 2020, 5:16:16 PM10/5/20
to emscripte...@googlegroups.com
Can you produce with a simple example?   if so perhaps open a bug.   This certainly doesn't happen in the general case so there must be some interesting thing you are doing.  e.g.

$ cat hello.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

int main(int argc, char* argv[]) {
  struct stat buf;
  printf("%d\n", stat("foo", &buf));
  return 0;
}
$ ./emcc  hello.c
$ node ./a.out.js
-1

cheers,
sam

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/45f78bba-2bd9-41bd-a9d3-df9d5ef2c605n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages