diff --git a/Makefile b/Makefile index eafa079..4c4ba4b 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC = gcc CFLAGS = -Wall -Wextra TARGET = cpetrat SRC = cpetrat.c -PREFIX = / +PREFIX = /usr/local $(TARGET): $(SRC) $(CC) $(CFLAGS) -o $(TARGET) $(SRC) diff --git a/cpetrat.c b/cpetrat.c index 0bafb33..aa1d0b6 100644 --- a/cpetrat.c +++ b/cpetrat.c @@ -6,10 +6,18 @@ void save(void) { char path[256]; +#ifdef __APPLE__ + snprintf(path, sizeof(path), "%s/Library/Application Support/rat", getenv("HOME")); +#else snprintf(path, sizeof(path), "%s/.local/share/rat", getenv("HOME")); +#endif mkdir(path, 0755); +#ifdef __APPLE__ + snprintf(path, sizeof(path), "%s/Library/Application Support/rat/rat.txt", getenv("HOME")); +#else + snprintf(path, sizeof(path), "%s/.local/share/rat/rat.txt", getenv("HOME")); +#endif - snprintf(path, sizeof(path), "%s/.local/share/rat/rat.txt", getenv("HOME")); FILE *f = fopen(path, "w"); if (!f) return; @@ -21,7 +29,11 @@ void save(void) { void load(void) { char path[256]; +#ifdef __APPLE__ + snprintf(path, sizeof(path), "%s/Library/Application Support/rat/rat.txt", getenv("HOME")); +#else snprintf(path, sizeof(path), "%s/.local/share/rat/rat.txt", getenv("HOME")); +#endif FILE *f = fopen(path, "r"); if (!f) { //first run @@ -57,7 +69,7 @@ void setstat(){ rat.health = decay(100.0f, newage, 0.00002f); - rat.age = timenow; + rat.age = timenow; //while asking grok if the ifdefs for the mac path where fine he said something about time() returning a 64 int in mac but i don't know what that means so i'll ignore it } void printrat(){