Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

RE: RE: Odd file rename

by Corion (Pope)
on Jun 14, 2000 at 16:54 UTC ( #18082=note: print w/replies, xml ) Need Help??


in reply to RE: Odd file rename
in thread Odd file rename

To be honest, I don't see where rename() would be less robust than the link() / unlink() combo. Both cases work only on the same file system, both cases do otherwise the Right Thing, except that rename() is atomic, where link / unlink are two different statements. In the case of failure, both statements leave the original file untouched, but if the unlink() fails, you are left with an additional link to the old file, which is not always what you want ...

Update : And even Larry Wall claims that rename is cool :

Besides, REAL computers have a rename() system call. :-)

Replies are listed 'Best First'.
RE: RE: RE: Odd file rename
by lhoward (Vicar) on Jun 14, 2000 at 17:07 UTC
    I proposed the link/unlink solution because IMHO it allows for finer granularity of error handling (not that my example took advantage of this, but I could have). Also, according to this earlier perlmonks article rename a user was experiencing rename failures which ended up deleting the file being renamed.

    Of course, this shouldn't be an issue if the perl rename function really just calls the system rename call. I guess this depends on which OS you are running.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://18082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2021-05-13 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (134 votes). Check out past polls.

    Notices?