summaryrefslogtreecommitdiffstats
path: root/src/history.c
diff options
context:
space:
mode:
authorSosthène Guédon <sosthene.gued@gmail.com>2019-06-16 11:13:07 +0200
committerSosthène Guédon <sosthene.gued@gmail.com>2019-06-16 11:13:07 +0200
commit6f1f41ffe3283a0bbfe2c2f745d348c30be2adbf (patch)
treec78bc0d57ee42837b2ba19c981748c0a984201ce /src/history.c
parente6c3e7bc11f2e7bdd845ec0a89172b84b26ad7ab (diff)
Partial fix to #336
Change history file location
Diffstat (limited to 'src/history.c')
-rw-r--r--src/history.c7
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;