mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Create mountpoint by hostname, clear prompt
This commit is contained in:
parent
f4ff4b0793
commit
32ec37a796
26
src/nnn.c
26
src/nnn.c
|
@ -4011,35 +4011,37 @@ static bool remote_mount(char *newpath)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
tmp = xreadline(NULL, "remote name: ");
|
||||
tmp = xreadline(NULL, "host[:dir] > ");
|
||||
if (!tmp[0]) {
|
||||
printmsg(messages[MSG_CANCEL]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Create the mount point */
|
||||
mkpath(cfgpath, toks[TOK_MNT], mntpath);
|
||||
mkpath(mntpath, tmp, newpath);
|
||||
if (!xmktree(newpath, TRUE)) {
|
||||
printwarn(NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Convert "Host" to "Host:" */
|
||||
size_t len = xstrlen(tmp);
|
||||
bool path = FALSE;
|
||||
|
||||
for (size_t count = 0; count < len; ++count)
|
||||
if (tmp[count] == ':') {
|
||||
tmp[count] = '\0';
|
||||
len = count;
|
||||
path = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!path) { /* Append ':' if missing */
|
||||
tmp[len] = ':';
|
||||
tmp[len + 1] = '\0';
|
||||
/* Create the mount point */
|
||||
mkpath(cfgpath, toks[TOK_MNT], mntpath);
|
||||
mkpath(mntpath, tmp, newpath);
|
||||
if (!xmktree(newpath, TRUE)) {
|
||||
printwarn(NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
tmp[len] = ':';
|
||||
|
||||
if (!path) /* Append ':' at the end */
|
||||
tmp[len + 1] = '\0';
|
||||
|
||||
/* Connect to remote */
|
||||
if (opt == 's') {
|
||||
if (spawn(env, tmp, newpath, flag)) {
|
||||
|
|
Loading…
Reference in a new issue