04-08-05 01:48 AM
In article <1112919832.716926.163690@o13g2000cwo.googlegroups.com>,
"blackdog" <cljlk@hotmail.com> wrote:
> I have an application which is written in C. The application contains
> command cp to copy a file to another file name, then use
> command rm to delete the original file. Some people think that is
> better then using command mv in a C program to rename a file because
> the mv command dose not always work in a C program, it get hung
> sometime.
> Would anyone please explain why and why not?
The mv command will use rename() if the source and destination are on
the same filesystem, which is *much* better.
If they're on different filesystems, mv works like cp followed by rm.
If cp succeeds, so should mv. You should probably use the -f option to
prevent mv from asking questions.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
[ Post a follow-up to this message ]
|