diff options
author | lum <lum@cvs.openbsd.org> | 2013-05-30 17:43:44 +0000 |
---|---|---|
committer | lum <lum@cvs.openbsd.org> | 2013-05-30 17:43:44 +0000 |
commit | a8fcdc1273c40d08bc18d15ef215f535956f5f32 (patch) | |
tree | 0aa7ecf1771e78275af5cacb8a12ed45c32e5b63 /usr.bin/mg | |
parent | 296a80d1ada7fc32000122b7bcbdcacf115d8c9f (diff) |
Use adjustname() for the dired-copy-file and dired-rename-file
commands.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r-- | usr.bin/mg/dired.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c index 8ad60d994ff..86c678d3309 100644 --- a/usr.bin/mg/dired.c +++ b/usr.bin/mg/dired.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dired.c,v 1.58 2013/05/30 04:27:18 lum Exp $ */ +/* $OpenBSD: dired.c,v 1.59 2013/05/30 17:43:43 lum Exp $ */ /* This file is in the public domain. */ @@ -398,10 +398,11 @@ d_expunge(int f, int n) int d_copy(int f, int n) { - char frname[NFILEN], toname[NFILEN], sname[NFILEN], *bufp; - int ret; - size_t off; - struct buffer *bp; + char frname[NFILEN], toname[NFILEN], sname[NFILEN]; + char *topath, *bufp; + int ret; + size_t off; + struct buffer *bp; if (d_makename(curwp->w_dotp, frname, sizeof(frname)) != FALSE) { ewprintf("Not a file"); @@ -419,7 +420,9 @@ d_copy(int f, int n) return (ABORT); else if (bufp[0] == '\0') return (FALSE); - ret = (copy(frname, toname) >= 0) ? TRUE : FALSE; + + topath = adjustname(toname, TRUE); + ret = (copy(frname, topath) >= 0) ? TRUE : FALSE; if (ret != TRUE) return (ret); if ((bp = refreshbuffer(curbp)) == NULL) @@ -431,7 +434,8 @@ d_copy(int f, int n) int d_rename(int f, int n) { - char frname[NFILEN], toname[NFILEN], *bufp; + char frname[NFILEN], toname[NFILEN]; + char *topath, *bufp; int ret; size_t off; struct buffer *bp; @@ -453,7 +457,9 @@ d_rename(int f, int n) return (ABORT); else if (bufp[0] == '\0') return (FALSE); - ret = (rename(frname, toname) >= 0) ? TRUE : FALSE; + + topath = adjustname(toname, TRUE); + ret = (rename(frname, topath) >= 0) ? TRUE : FALSE; if (ret != TRUE) return (ret); if ((bp = refreshbuffer(curbp)) == NULL) |