|go ahead... be a heretic|
How does rename() work on read-only files?by j41r (Beadle)
|on Dec 11, 2018 at 00:56 UTC||Need Help??|
j41r has asked for the wisdom of the Perl Monks concerning the following question:
I'm one of the weird people that hates to ask questions but instead loves to RTFM. This time I'm really stuck with this subject that I'm pretty sure is trivial for all of you but, for me, it's so important that I didn't hesitate to raise my hand to ask about it, so here you go:
I was reading about Why does Perl let me delete read only files? Why does i clobber protected files? Isn't this a bug in Perl?, and while the executive summary was pretty much understandable, that wasn't enough for me and I went the extra mile by reading the elaborately and painstakingly explanation available in the file file-dir-perms
That's an amazing explanation, however how rename() actually works on read-only files just went over my head. Could anyone please help me out understand these two cases?
I also read How can I reliably rename a file?, which says (emphasis mine):
It may be more portable to use the File::Copy module instead. You just copy to the new file to the new name (checking return values), then delete the old one. This isn't really the same semantically as a rename(), which preserves meta-information like permissions, timestamps, inode info, etc.
but it seams to just add insult to injury, so any help would be appreciated.