diff options
author | Rob Landley <rob@landley.net> | 2018-12-14 21:22:10 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-12-14 21:22:10 -0600 |
commit | c2a44fbe073fb13ab9407ac3a072c7b847383b62 (patch) | |
tree | b819f38f764fad30ee6ae1182d8bc054471f9f08 /lib | |
parent | d4017dbd0a422953bc439db467db9c36d5dd4e33 (diff) | |
download | toybox-c2a44fbe073fb13ab9407ac3a072c7b847383b62.tar.gz |
Add xrename()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 2 | ||||
-rw-r--r-- | lib/lib.h | 1 | ||||
-rw-r--r-- | lib/xwrap.c | 5 |
3 files changed, 7 insertions, 1 deletions
@@ -747,7 +747,7 @@ void replace_tempfile(int fdin, int fdout, char **tempname) xclose(fdin); } xclose(fdout); - rename(*tempname, temp); + xrename(*tempname, temp); tempfile2zap = (char *)1; free(*tempname); free(temp); @@ -138,6 +138,7 @@ int xrun(char **argv); int xpspawn(char **argv, int*pipes); void xaccess(char *path, int flags); void xunlink(char *path); +void xrename(char *from, char *to); int xtempfile(char *name, char **tempname); int xcreate(char *path, int flags, int mode); int xopen(char *path, int flags); diff --git a/lib/xwrap.c b/lib/xwrap.c index 2027069d..b2416a4e 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -378,6 +378,11 @@ int notstdio(int fd) return fd; } +void xrename(char *from, char *to) +{ + if (rename(from, to)) perror_exit("rename %s -> %s", from, to); +} + int xtempfile(char *name, char **tempname) { int fd; |