'Rename' Library Function?
Conor P. Cahill
cpcahil at virtech.UUCP
Wed Sep 20 02:38:22 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)
^^^ AUX?
> system, which has a 'rename' library function, it bombs on that function,
> returning an 'unresolved external' error on _rename.
The problem is due to the fact that AUX is *probably* BSD based and has the
rename(2) system call. This system call is not available in plain jane
system V systems. Although xenix is not plain jane system V, it is not
based upon BSD and does not include the rename system call.
> 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);
You neet to write a rename function that should do the following:
rename(src,tgt)
char * src;
char * tgt;
{
if( (link(src,tgt) == -1) || (unlink(src) == -1) )
return(-1);
return(0);
}
--
+-----------------------------------------------------------------------+
| Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 !
| Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 |
+-----------------------------------------------------------------------+
More information about the Comp.unix.xenix
mailing list