Small snake game in C
Commit b806cbd5647f
tarball2 files changed+8-4
@@ -43,15 +43,17 @@ int main(int argc, char *args[]) {
4343
printf("are you ok?\n");4444
return 1;4545
}46
- 46
+ 47
+ errno = 0;4748
snprintf(file_path, sizeof(file_path), "%s/.local", env);48
- if (mkdir(file_path, 0755)) {49
+ if (mkdir(file_path, 0755) && errno != EEXIST) {4950
printf("couldn't create folder");5051
return 1;5152
}5253
54
+ errno = 0;5355
snprintf(file_path, sizeof(file_path), "%s/.local/share", env);54
- if (mkdir(file_path, 0755)) {56
+ if (mkdir(file_path, 0755) && errno != EEXIST) {5557
printf("couldn't create folder");5658
return 1;5759
}@@ -13,7 +13,9 @@
1313
#include <stdlib.h>1414
1515
#include <sys/ioctl.h>16
- #include <sys/stat.h>16
+#include <sys/stat.h>17
+18
+#include <errno.h>1719
1820
#include <time.h>