Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: [OT] rename(2) -- renaming file to itself produces no error.

by Coruscate (Sexton)
on Jan 08, 2004 at 05:30 UTC ( [id://319730]=note: print w/replies, xml ) Need Help??


in reply to Re: [OT] rename(2) -- renaming file to itself produces no error.
in thread [OT] rename(2) -- renaming file to itself produces no error.

I don't know, the rationale seems quite reasonable to me. I don't know the technical aspects of rename, but I assume that the file is copied and then the one that was copied is removed, making it so that a copy of this file is guaranteed to exist in full somewhere on the filesystem. If this is indeed the method used, how would you go about moving a file to the same path? You'd have to hold the entire file contents in memory, delete the original file, then create the "new" file and place the in-memory contents back in. (Or you could use a temp file rather than memory). This would leave somewhat of an undesirable race condition in which a file we are renaming doesn't exist on the filesystem at all.

This doesn't answer the "why is there no error" question, but I don't see why there should be.

  • Comment on Re^2: [OT] rename(2) -- renaming file to itself produces no error.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-19 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found