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