aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-06-08 21:56:33 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-06-08 21:56:33 +0530
commitc5f0a25e7e8bf09df7f495af907f8a7d4f967cbd (patch)
tree83fd9787409deded49163526c65976ec60b31e92
parentd19d8d5f02b9ce5635c9deab11371531ee65dcf1 (diff)
downloadnnn-c5f0a25e7e8bf09df7f495af907f8a7d4f967cbd.tar.gz
Simplify subdir creation
-rw-r--r--plugins/README.md2
-rw-r--r--src/nnn.c39
2 files changed, 13 insertions, 28 deletions
diff --git a/plugins/README.md b/plugins/README.md
index bb90a26..aa6749d 100644
--- a/plugins/README.md
+++ b/plugins/README.md
@@ -4,7 +4,7 @@
<p align="center"><i>read ebooks with plugin gutenread (Android)</i></p>
<p align="center"><a href="https://asciinema.org/a/336443"><img src="https://asciinema.org/a/336443.png" width="734"/></a></p>
-<p align="center"><i>Live Previews</i></p>
+<p align="center"><i>Live Previews asciicast</i></p>
## Introduction
diff --git a/src/nnn.c b/src/nnn.c
index 0d518a5..49fd70b 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -629,14 +629,14 @@ static char mv[] = "mv -i";
#endif
/* Tokens used for path creation */
-#define TOK_PLG 0
-#define TOK_SSN 1
-#define TOK_MNT 2
+#define TOK_SSN 0
+#define TOK_MNT 1
+#define TOK_PLG 2
static const char * const toks[] = {
- "plugins",
"sessions",
"mounts",
+ "plugins", /* must be the last entry */
};
/* Patterns */
@@ -6873,29 +6873,14 @@ static bool setup_config(void)
xstrsncpy(cfgpath + r - 1, "/nnn", len - r);
DPRINTF_S(cfgpath);
- /* Create ~/.config/nnn/plugins */
- mkpath(cfgpath, toks[TOK_PLG], plgpath);
- if (!xmktree(plgpath, TRUE)) {
- xerror();
- return FALSE;
- }
-
- /* Create ~/.config/nnn/sessions */
- char ssnpath[len];
-
- mkpath(cfgpath, toks[TOK_SSN], ssnpath);
- if (!xmktree(ssnpath, TRUE)) {
- xerror();
- return FALSE;
- }
-
- /* Create ~/.config/nnn/mounts */
- char mntpath[len];
-
- mkpath(cfgpath, toks[TOK_MNT], mntpath);
- if (!xmktree(mntpath, TRUE)) {
- xerror();
- return FALSE;
+ /* Create sessions, mounts and plugins directories */
+ for (r = 0; r < ELEMENTS(toks); ++r) {
+ mkpath(cfgpath, toks[r], plgpath);
+ if (!xmktree(plgpath, TRUE)) {
+ DPRINTF_S(toks[r]);
+ xerror();
+ return FALSE;
+ }
}
/* Set selection file path */