diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2011-10-23 08:34:01 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2011-10-23 08:34:01 +0000 |
commit | 7ff4cf94050e11517bb6fa89be2f5f4c85af12e3 (patch) | |
tree | c7d09a942ab3b667d9bb3f009523ed9fcfa3d402 /cmd-load-buffer.c | |
parent | 179d0686d78ec6489572e122dbb50220471531a2 (diff) | |
download | rtmux-7ff4cf94050e11517bb6fa89be2f5f4c85af12e3.tar.gz rtmux-7ff4cf94050e11517bb6fa89be2f5f4c85af12e3.tar.bz2 rtmux-7ff4cf94050e11517bb6fa89be2f5f4c85af12e3.zip |
Try to resolve relative paths for loadb and saveb (first using client
working directory if any then default-path or session wd).
Diffstat (limited to 'cmd-load-buffer.c')
-rw-r--r-- | cmd-load-buffer.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index a14f699e..09fddbf7 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -48,8 +48,9 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct client *c = ctx->cmdclient; + struct session *s; FILE *f; - const char *path; + const char *path, *newpath, *wd; char *pdata, *new_pdata, *cause; size_t psize; u_int limit; @@ -93,6 +94,19 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) return (1); } + if (c != NULL) + wd = c->cwd; + else if ((s = cmd_current_session(ctx, 0)) != NULL) { + wd = options_get_string(&s->options, "default-path"); + if (*wd == '\0') + wd = s->cwd; + } else + wd = NULL; + if (wd != NULL && *wd != '\0') { + newpath = get_full_path(wd, path); + if (newpath != NULL) + path = newpath; + } if ((f = fopen(path, "rb")) == NULL) { ctx->error(ctx, "%s: %s", path, strerror(errno)); return (-1); |