home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
RENAME.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
638b
|
34 lines
/* a public domain rename, by ERS */
#include <limits.h>
#include <errno.h>
#include <osbind.h>
#include <string.h>
#include <unistd.h>
#include "lib.h"
int rename(_oldname, _newname)
const char *_oldname, *_newname;
{
char oldname[PATH_MAX], newname[PATH_MAX];
int rval;
if (!strcmp(_oldname, _newname)) {
rval = 0; /* no-op */
}
if (!access(_newname, 0)) { /* new name already exists */
if (unlink(_newname))
return -1;
}
_unx2dos(_oldname, oldname);
_unx2dos(_newname, newname);
if ( (rval = Frename(0, oldname, newname)) < 0 ) {
errno = -rval;
rval = -1;
}
return rval;
}