1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)rename_.c 5.2 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 /* 13 * rename a file atomically 14 * 15 * synopsis: 16 * integer function rename (from, to) 17 * character*(*) from, to 18 * 19 * where: 20 * return value will be zero normally, an error number otherwise. 21 */ 22 23 #include "../libI77/f_errno.h" 24 #include <sys/param.h> 25 #ifndef MAXPATHLEN 26 #define MAXPATHLEN 128 27 #endif 28 29 long 30 rename_ (from, to, frlen, tolen) 31 char *from, *to; 32 long frlen, tolen; 33 { 34 char frbuf[MAXPATHLEN]; 35 char tobuf[MAXPATHLEN]; 36 37 if (frlen <= 0 || tolen <= 0 || *from == ' ' || *to == ' ') 38 return ((long)(errno = F_ERARG)); 39 if (frlen >= sizeof frbuf || tolen >= sizeof tobuf) 40 return ((long)(errno = F_ERARG)); 41 g_char (from, frlen, frbuf); 42 g_char (to, tolen, tobuf); 43 if (rename (from, to) != 0) 44 return ((long)errno); 45 return (0L); 46 } 47