in reply to Re^5: Read in hostfile, modify, output
in thread Read in hostfile, modify, output

Atomic rename is specified by POSIX, nothing "specialized" about it. Yes, Windows is more complicated and you have a point in that case, but newer versions of Windows provide some advanced API functions.

Most modern filesystems, like ext3, ext4, NTFS, and HFS+ support journaling, so "The vast majority of folks here" with their "standard versions of Windows or Unix variants" are already using them. Do you still think "There is no truly atomic operation on the file system"?

Replies are listed 'Best First'.
Re^7: Read in hostfile, modify, output
by Marshall (Canon) on Dec 21, 2016 at 01:27 UTC
    "Atomic rename()" by POSIX specifies a single rename operation.

    Show some working code that demo's replacing a file using Perl that uses a single rename.

      echo foo>foo; echo bar>bar; perl -e 'rename("foo","bar")' works perfectly fine on Linux. But I don't get why you wanted me to test it, when I know what I'm talking about and I knew it would work ahead of time (but I did test again anyway just to make sure I don't look like a fool), whereas if you had read up on the subject and tested before posting you might have learned something that it seems you didn't know before.
        ... just to make sure I don't look like a fool ...

        Don't worry about that. The Anonymous Monk already looks a fool as the result of many and many a post, and nothing you or anyone else can do can change that. Now, had you a handle... :)


        Give a man a fish:  <%-{-{-{-<

        I wanted to see what would happen under your Linux system (Request for testing). Right now, I don't have a Unix box to test with and so I couldn't test on Linux before posting. I did test under Windows which is what I have.

        The OP was asking about Windows. There appears to be a difference between Win and Linux. Fair enough. And a good point. The details of how these file system operators actually work between OS'es requires experimentation. I have no problem with that idea - I believe it.