cross-platform home dir in pure C
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#define PATH_LEN 256 | |
int main(void) | |
{ | |
char path[PATH_LEN]; | |
FILE *pipe; | |
if(!(pipe = popen("scala -e 'print(sys.props(\"user.home\"))'", "r"))) | |
{ | |
fprintf(stderr, "Error\n"); | |
exit(1); | |
} | |
memset(path, 0, PATH_LEN); | |
fgets(path, PATH_LEN-1, pipe); | |
printf("User directory: %s\n", path); | |
pclose(pipe); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment