jag

jagWrite_c

public

library to write to files for my games

Star0
Watch0

Commit 33d0ad331ce3

tarball

Jaglekon <58274093+Jaglekon@users.noreply.github.com>2026-08-28 21:25 UTC

2 files changed+38-0
lib update 1
Modified file: include/jag_write.h+9 additions
@@ -16,6 +16,15 @@
1616 #include <ctype.h>
1717 #include <string.h>
1818
19+#include <limits.h>
20+
21+
22+#define LOCAL "/.local"
23+#define SHARE "/share"
24+
25+
1926 uint8_t make_folder(char *path);
2027
28+uint8_t create_settings_folder(char folder_path[PATH_MAX]);
29+
2130 #endif
Modified file: source/jag_write.c+29 additions
@@ -10,3 +10,32 @@ uint8_t make_folder(char *path) {
1010 return 1;
1111 }
1212
13+
14+uint8_t create_xdg_folder(char folder_path[PATH_MAX]) {
15+ char *env;
16+
17+ if ((env = getenv("XDG_DATA_HOME")) == NULL) {
18+ if ((env = getenv("HOME")) == NULL) {
19+ printf("are you ok?\n");
20+ return 0;
21+ }
22+
23+ uint8_t error = 0;
24+
25+ sprintf(folder_path, "%s%s", env, LOCAL);
26+ error += make_folder(folder_path);
27+
28+ strcat(folder_path, SHARE);
29+ error += make_folder(folder_path);
30+
31+ if (error <= 1) {
32+ printf("Failed to create Folder");
33+ return 0;
34+ }
35+ } else {
36+ sprintf(folder_path, "%s", env);
37+ }
38+
39+ return 1;
40+}
41+