Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!evax!utacfd!letni!texsun!playroom!gaffa.East.Sun.COM!cliffs From: cliffs@gaffa.East.Sun.COM (Clifford C. Skolnick) Newsgroups: comp.unix.questions Subject: Re: mv'ing files from a C program Message-ID: <497@playroom.UUCP> Date: 15 Nov 90 20:59:33 GMT References: <22@mixcom.UUCP> Sender: news@playroom.UUCP Distribution: na Organization: Sun Microsystems, Inc. Rochester, NY Lines: 29 In article <22@mixcom.UUCP> ggvvgg@mixcom.UUCP (Dave Fenske) writes: >Is there an easy way to do an 'mv' from a C program? > >I just want to be able to move a recently read file into another directory, >and wish to avoid having to write it there. Using the 'system' call is >not deemed wiable for this application. > >DF Do it like "mv" int mv(oldpath, newpath) char *oldpath, *newpath; { int ret; if (ret = link(oldpath, newpath)) return(ret); /* an error has occured */ if (ret = unlink(oldpath)) return(ret); /* gee, another error */ return(0); } -- Cliff Skolnick - Technical Consultant | (716) 385-5049 | cliffs@east.sun.com [I only work for Sun, I do not speak for them] "The floggings will continue until morale improves"