[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH 1/2] history: create the path '~/.local/share/' when
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH 1/2] history: create the path '~/.local/share/' when it is needed |
Date: |
Sat, 25 Nov 2017 12:30:24 +0100 |
On a freshly installed system, or for a new user, the default
XDG data directory may not exist yet. So, create it when not.
Reported-by: Brand Huntsman <address@hidden>
---
src/history.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/history.c b/src/history.c
index 9af9a177..c9eab1e8 100644
--- a/src/history.c
+++ b/src/history.c
@@ -26,10 +26,6 @@
#ifdef ENABLE_HISTORIES
-#ifndef XDG_DATA_FALLBACK
-#define XDG_DATA_FALLBACK "/.local/share"
-#endif
-
#ifndef SEARCH_HISTORY
#define SEARCH_HISTORY "search_history"
#endif
@@ -272,9 +268,17 @@ bool have_statedir(void)
if (xdgdatadir != NULL)
statedir = concatenate(xdgdatadir, "/nano/");
else
- statedir = concatenate(homedir, XDG_DATA_FALLBACK "/nano/");
+ statedir = concatenate(homedir, "/.local/share/nano/");
if (stat(statedir, &dirstat) == -1) {
+ if (xdgdatadir == NULL) {
+ char *statepath = concatenate(homedir, "/.local");
+ mkdir(statepath, S_IRWXU | S_IRWXG | S_IRWXO);
+ free(statepath);
+ statepath = concatenate(homedir, "/.local/share");
+ mkdir(statepath, S_IRWXU);
+ free(statepath);
+ }
if (mkdir(statedir, S_IRWXU | S_IRWXG | S_IRWXO) == -1) {
history_error(N_("Unable to create directory %s: %s\n"
"It is required for saving/loading "
--
2.14.3
- [Nano-devel] [PATCH 1/2] history: create the path '~/.local/share/' when it is needed,
Benno Schulenberg <=