• (nodebb)

    Dateline : 2025/11/26.

    There are no comments on this article yet (there will be in a moment), which might be because the actual dateline on the article is 2025/12/02, and yet the Random Article button let me see it anyway...

  • L (unregistered) in reply to Steve_The_Cynic

    did you submit it to last week Error'd?

  • (nodebb) in reply to L

    Unfortunately, I didn't think of doing that at the time, then I forgot about it in the meantime, until I saw it come up today.

  • (nodebb)

    Ooohhh, that would have been WAY too much fun!

    I need to get out more....

  • (nodebb)

    I'm going to go out on a limb and assume ExtractFileName isn't a pure function either, which would make debugging all the more painful.

  • (nodebb)

    It seems a fairly minor WTF but the whole

    if FileExists(someFile) then
    begin
      { do something with someFile }
    end;
    

    is itself a WTF since there is a race condition in that, if it exists, something else might have deleted it before you get to do what you want to do with it. You might as well just go ahead and do the operation without testing for existence and handle the errors if they arise.

  • (nodebb)

    ExtractFileName is a pure function. It returns the argument without the drive and directory.

  • (nodebb) in reply to jeremypnet

    Yeah, what I tend to call a "toctou" == "Time of Check, Time of Use" (name derived from the reports from the static analyser we use at $JOB).

  • (nodebb)

    Back in Ye Olden Dayes of computers running one app at a time and no multi-threading, TOCTOU (an industry standard term) wasn't nearly the code smell it is today. Given that we're talking about Delphi, decent bet this is a nearly single-threaded application where the only thing that could disturb that file between check and use is a hard drive failure. Or maybe somebody opening the floppy drive door at just the right moment. ;)

    Also back in Ye Olden Dayes the way you checked for errors in most languages was itself pretty laborious, code intensive, and bug-prone. From a code cleanliness perspective they're probably better off the way they are.

    Addendum 2025-12-02 10:28: Would I recommend writing TOCTOU bugs in a modern multi-threaded multi-user app written in a modern exception-driven language?

    Of course not.

  • The Future (unregistered) in reply to Steve_The_Cynic

    Hello from the future!

  • (nodebb) in reply to WTFGuy

    And yet people still do it. TOCTOU is what took down US-EAST-1 AWS a little while ago.

Leave a comment on “The Destination Dir”

Log In or post as a guest

Replying to comment #687961:

« Return to Article