-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
Considering the following:
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
static void create_file(const char *path, const char *buffer, int mode) {
int fd = open(path, O_WRONLY | O_CREAT | O_EXCL, mode);
assert(fd >= 0);
int err = write(fd, buffer, sizeof(char) * strlen(buffer));
assert(err == (sizeof(char) * strlen(buffer)));
close(fd);
}
int main() {
char buf[20];
create_file("symlink_target", "xyz", 0777);
symlink("symlink_target", "symlink_src");
readlink("symlink_src", buf, 20);
printf("buf: '%s'\n", buf);
unlink("symlink_src");
unlink("symlink_target");
}
Running with gcc
we just the contents of the link vs running with emcc
we get a fully qualified path:
$ gcc a.c
$ ./a.out
buf: 'symlink_target'
$ emcc a.c
$ node a.out.js
buf: '/symlink_target'
Note the initial /
in the emcc run.
Metadata
Metadata
Assignees
Labels
No labels