mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Simplify subdir creation
This commit is contained in:
parent
d19d8d5f02
commit
c5f0a25e7e
|
@ -4,7 +4,7 @@
|
||||||
<p align="center"><i>read ebooks with plugin gutenread (Android)</i></p>
|
<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"><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
|
## Introduction
|
||||||
|
|
||||||
|
|
31
src/nnn.c
31
src/nnn.c
|
@ -629,14 +629,14 @@ static char mv[] = "mv -i";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Tokens used for path creation */
|
/* Tokens used for path creation */
|
||||||
#define TOK_PLG 0
|
#define TOK_SSN 0
|
||||||
#define TOK_SSN 1
|
#define TOK_MNT 1
|
||||||
#define TOK_MNT 2
|
#define TOK_PLG 2
|
||||||
|
|
||||||
static const char * const toks[] = {
|
static const char * const toks[] = {
|
||||||
"plugins",
|
|
||||||
"sessions",
|
"sessions",
|
||||||
"mounts",
|
"mounts",
|
||||||
|
"plugins", /* must be the last entry */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Patterns */
|
/* Patterns */
|
||||||
|
@ -6873,29 +6873,14 @@ static bool setup_config(void)
|
||||||
xstrsncpy(cfgpath + r - 1, "/nnn", len - r);
|
xstrsncpy(cfgpath + r - 1, "/nnn", len - r);
|
||||||
DPRINTF_S(cfgpath);
|
DPRINTF_S(cfgpath);
|
||||||
|
|
||||||
/* Create ~/.config/nnn/plugins */
|
/* Create sessions, mounts and plugins directories */
|
||||||
mkpath(cfgpath, toks[TOK_PLG], plgpath);
|
for (r = 0; r < ELEMENTS(toks); ++r) {
|
||||||
|
mkpath(cfgpath, toks[r], plgpath);
|
||||||
if (!xmktree(plgpath, TRUE)) {
|
if (!xmktree(plgpath, TRUE)) {
|
||||||
|
DPRINTF_S(toks[r]);
|
||||||
xerror();
|
xerror();
|
||||||
return FALSE;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set selection file path */
|
/* Set selection file path */
|
||||||
|
|
Loading…
Reference in a new issue