|
|
1.1 ! root 1: /* ! 2: char id_rename[] = "@(#)rename_.c 1.2"; ! 3: * ! 4: * rename a file atomically ! 5: * ! 6: * synopsis: ! 7: * integer function rename (from, to) ! 8: * character*(*) from, to ! 9: * ! 10: * where: ! 11: * return value will be zero normally, an error number otherwise. ! 12: */ ! 13: ! 14: #include "../libI77/f_errno.h" ! 15: #include <sys/param.h> ! 16: #ifndef MAXPATHLEN ! 17: #define MAXPATHLEN 128 ! 18: #endif ! 19: ! 20: long ! 21: rename_ (from, to, frlen, tolen) ! 22: char *from, *to; ! 23: long frlen, tolen; ! 24: { ! 25: char frbuf[MAXPATHLEN]; ! 26: char tobuf[MAXPATHLEN]; ! 27: ! 28: if (frlen <= 0 || tolen <= 0 || *from == ' ' || *to == ' ') ! 29: return ((long)(errno = F_ERARG)); ! 30: if (frlen >= sizeof frbuf || tolen >= sizeof tobuf) ! 31: return ((long)(errno = F_ERARG)); ! 32: g_char (from, frlen, frbuf); ! 33: g_char (to, tolen, tobuf); ! 34: if (rename (from, to) != 0) ! 35: return ((long)errno); ! 36: return (0L); ! 37: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.