Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.xenix Subject: Re: 'Rename' Library Function? Keywords: rename lib Message-ID: <1179@virtech.UUCP> Date: 19 Sep 89 16:38:22 GMT References: <[157]unix@oldcolo.UUCP> Organization: Virtual Technologies Inc Lines: 37 In article <[157]unix@oldcolo.UUCP>, dave@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 | +-----------------------------------------------------------------------+