Answer the question
In order to leave comments, you need to log in
Why doesn't mkdir create a folder?
mkdir returns -1 for some reason.
If you remove homedir->str and write the path yourself, then everything works.
//check if dir exists
struct stat st = {0};
GString* homedir = g_string_new(NULL);
g_string_append(homedir, getenv("HOME"));
g_string_append(homedir, ".some/qwe");
printf("%s", homedir->str);
if (stat(&homedir->str, &st) == -1) {
int res= mkdir(homedir->str, 0777);
}
Answer the question
In order to leave comments, you need to log in
mkdir returns -1 for some reason
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question