'Rename' Library Function?
Karl Denninger
karl at ddsw1.MCS.COM
Wed Sep 20 10:14:35 AEST 1989
In article <[157]unix at oldcolo.UUCP> dave at oldcolo.UUCP (Dave Hughes) writes:
>WHen I try to compile an indexing program written on a Mac (AIX I think)
>system, which has a 'rename' library function, it bombs on that function,
>returning an 'unresolved external' error on _rename.
>
>It is used - and needed - in the following type of use:
>
> char oldname[32], finalname[65];
> sprintf (oldname, "x%dk0", generation_number);
> sprintf (finalname, "%s.k", doc_filename);
> if (rename (oldname, finalname))
> printf ("Sorry -- error in renaming file %s to %s!\n", oldname,
> finalname);
>
>I cannot find another 386 Xenix compiler library function which will
>work in its place. Any suggestions?
Sure Dave!
Try this replacement:
int rename(oname, fname) /* Returns zero if ok, NZ otherwise */
char *oname;
char *nname;
{
if (link(oname, nname)) { /* Try to make a link */
perror("failed"); /* Something is wrong, complain */
return(1); /* Failed to make a link */
}
return(unlink(oname)); /* Remove old name / return status */
}
Include that somewhere and it should replace your missing function. Note
that this will not work if the new name (fname) is on a different file system.
(Ps: I noted that your message came from AKCS; glad to see you have the
linkage working properly! :-))
--
Karl Denninger (karl at ddsw1.MCS.COM, <well-connected>!ddsw1!karl)
Public Access Data Line: [+1 312 566-8911], Voice: [+1 312 566-8910]
Macro Computer Solutions, Inc. "Quality Solutions at a Fair Price"
More information about the Comp.unix.xenix
mailing list