diff options
author | Sosthène Guédon <sosthene.gued@gmail.com> | 2019-06-16 11:13:07 +0200 |
---|---|---|
committer | Sosthène Guédon <sosthene.gued@gmail.com> | 2019-06-16 11:13:07 +0200 |
commit | 6f1f41ffe3283a0bbfe2c2f745d348c30be2adbf (patch) | |
tree | c78bc0d57ee42837b2ba19c981748c0a984201ce /src/history.c | |
parent | e6c3e7bc11f2e7bdd845ec0a89172b84b26ad7ab (diff) |
Partial fix to #336
Change history file location
Diffstat (limited to 'src/history.c')
-rw-r--r-- | src/history.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/history.c b/src/history.c index f7c1e0b..64fd77f 100644 --- a/src/history.c +++ b/src/history.c @@ -100,6 +100,7 @@ void set_comp(int i) { #include <stdlib.h> #include <fcntl.h> #include <unistd.h> +#include <sys/stat.h> #include "history.h" #include "sc.h" @@ -193,13 +194,15 @@ int save_history(struct history * h, char * mode) { FILE * f; int i; struct hlist * nl = h->list; - if ((home = getenv("HOME"))) { + char history_folder[PATHLEN]; + sprintf(history_folder, "%s/", home); + strcat(history_folder, HISTORY_FOLDER); + mkdir(history_folder,0777); sprintf(infofile, "%s/", home); strcat(infofile, HISTORY_FILE); f = fopen(infofile, mode); if (f == NULL) return 0; - // Go to the end for (i=1; i < h->len; i++) { nl = nl->pnext; |