浏览代码

Create mountpoint by hostname, clear prompt

master
Arun Prakash Jana 4 年前
父节点
当前提交
32ec37a796
找不到此签名对应的密钥 GPG 密钥 ID: A75979F35C080412
共有 1 个文件被更改,包括 14 次插入12 次删除
  1. +14
    -12
      src/nnn.c

+ 14
- 12
src/nnn.c 查看文件

@@ -4011,35 +4011,37 @@ static bool remote_mount(char *newpath)
return FALSE; return FALSE;
} }


tmp = xreadline(NULL, "remote name: "); tmp = xreadline(NULL, "host[:dir] > ");
if (!tmp[0]) { if (!tmp[0]) {
printmsg(messages[MSG_CANCEL]); printmsg(messages[MSG_CANCEL]);
return FALSE; 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:" */ /* Convert "Host" to "Host:" */
size_t len = xstrlen(tmp); size_t len = xstrlen(tmp);
bool path = FALSE; bool path = FALSE;


for (size_t count = 0; count < len; ++count) for (size_t count = 0; count < len; ++count)
if (tmp[count] == ':') { if (tmp[count] == ':') {
tmp[count] = '\0';
len = count;
path = TRUE; path = TRUE;
break; break;
} }


if (!path) { /* Append ':' if missing */ /* Create the mount point */
tmp[len] = ':'; mkpath(cfgpath, toks[TOK_MNT], mntpath);
tmp[len + 1] = '\0'; 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 */ /* Connect to remote */
if (opt == 's') { if (opt == 's') {
if (spawn(env, tmp, newpath, flag)) { if (spawn(env, tmp, newpath, flag)) {


||||||
x
 
000:0
正在加载...
取消
保存