mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Subdir 'mounts' for remote/archive mounts
This commit is contained in:
parent
fdfbac0386
commit
b62adec72c
32
src/nnn.c
32
src/nnn.c
|
@ -369,6 +369,7 @@ static char *listpath;
|
||||||
static char *prefixpath;
|
static char *prefixpath;
|
||||||
static char *plugindir;
|
static char *plugindir;
|
||||||
static char *sessiondir;
|
static char *sessiondir;
|
||||||
|
static char *mountdir;
|
||||||
static char *pnamebuf, *pselbuf;
|
static char *pnamebuf, *pselbuf;
|
||||||
static char *mark;
|
static char *mark;
|
||||||
#ifndef NOFIFO
|
#ifndef NOFIFO
|
||||||
|
@ -3904,7 +3905,7 @@ static bool archive_mount(char *newpath)
|
||||||
DPRINTF_S(dir);
|
DPRINTF_S(dir);
|
||||||
|
|
||||||
/* Create the mount point */
|
/* Create the mount point */
|
||||||
mkpath(cfgdir, dir, newpath);
|
mkpath(mountdir, dir, newpath);
|
||||||
free(dir);
|
free(dir);
|
||||||
|
|
||||||
if (!xmktree(newpath, TRUE)) {
|
if (!xmktree(newpath, TRUE)) {
|
||||||
|
@ -3957,7 +3958,7 @@ static bool remote_mount(char *newpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the mount point */
|
/* Create the mount point */
|
||||||
mkpath(cfgdir, tmp, newpath);
|
mkpath(mountdir, tmp, newpath);
|
||||||
if (!xmktree(newpath, TRUE)) {
|
if (!xmktree(newpath, TRUE)) {
|
||||||
printwarn(NULL);
|
printwarn(NULL);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -4013,8 +4014,8 @@ static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (tmp && strcmp(cfgdir, currentpath) == 0) {
|
if (tmp && strcmp(mountdir, currentpath) == 0) {
|
||||||
mkpath(cfgdir, tmp, newpath);
|
mkpath(mountdir, tmp, newpath);
|
||||||
child = lstat(newpath, &sb) != -1;
|
child = lstat(newpath, &sb) != -1;
|
||||||
parent = lstat(xdirname(newpath), &psb) != -1;
|
parent = lstat(xdirname(newpath), &psb) != -1;
|
||||||
if (!child && !parent) {
|
if (!child && !parent) {
|
||||||
|
@ -4031,7 +4032,7 @@ static bool unmount(char *name, char *newpath, int *presel, char *currentpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the mount point */
|
/* Create the mount point */
|
||||||
mkpath(cfgdir, tmp, newpath);
|
mkpath(mountdir, tmp, newpath);
|
||||||
if (!xdiraccess(newpath)) {
|
if (!xdiraccess(newpath)) {
|
||||||
*presel = MSGWAIT;
|
*presel = MSGWAIT;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -6830,6 +6831,7 @@ static bool setup_config(void)
|
||||||
cfgdir = (char *)malloc(len);
|
cfgdir = (char *)malloc(len);
|
||||||
plugindir = (char *)malloc(len);
|
plugindir = (char *)malloc(len);
|
||||||
sessiondir = (char *)malloc(len);
|
sessiondir = (char *)malloc(len);
|
||||||
|
mountdir = (char *)malloc(len);
|
||||||
if (!cfgdir || !plugindir || !sessiondir) {
|
if (!cfgdir || !plugindir || !sessiondir) {
|
||||||
xerror();
|
xerror();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -6852,21 +6854,22 @@ static bool setup_config(void)
|
||||||
DPRINTF_S(cfgdir);
|
DPRINTF_S(cfgdir);
|
||||||
|
|
||||||
/* Create ~/.config/nnn/plugins */
|
/* Create ~/.config/nnn/plugins */
|
||||||
xstrsncpy(plugindir, cfgdir, PATH_MAX);
|
mkpath(cfgdir, "plugins", plugindir);
|
||||||
xstrsncpy(plugindir + r + 4 - 1, "/plugins", 9); /* subtract length of "/nnn" (4) */
|
if (!xmktree(plugindir, TRUE)) {
|
||||||
DPRINTF_S(plugindir);
|
|
||||||
|
|
||||||
if (access(plugindir, F_OK) && !xmktree(plugindir, TRUE)) {
|
|
||||||
xerror();
|
xerror();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create ~/.config/nnn/sessions */
|
/* Create ~/.config/nnn/sessions */
|
||||||
xstrsncpy(sessiondir, cfgdir, PATH_MAX);
|
mkpath(cfgdir, "sessions", sessiondir);
|
||||||
xstrsncpy(sessiondir + r + 4 - 1, "/sessions", 10); /* subtract length of "/nnn" (4) */
|
if (!xmktree(sessiondir, TRUE)) {
|
||||||
DPRINTF_S(sessiondir);
|
xerror();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (access(sessiondir, F_OK) && !xmktree(sessiondir, TRUE)) {
|
/* Create ~/.config/nnn/mounts */
|
||||||
|
mkpath(cfgdir, "mounts", mountdir);
|
||||||
|
if (!xmktree(mountdir, TRUE)) {
|
||||||
xerror();
|
xerror();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -6914,6 +6917,7 @@ static void cleanup(void)
|
||||||
free(selpath);
|
free(selpath);
|
||||||
free(plugindir);
|
free(plugindir);
|
||||||
free(sessiondir);
|
free(sessiondir);
|
||||||
|
free(mountdir);
|
||||||
free(cfgdir);
|
free(cfgdir);
|
||||||
free(initpath);
|
free(initpath);
|
||||||
free(bmstr);
|
free(bmstr);
|
||||||
|
|
Loading…
Reference in a new issue