For context, I am trying to do a save system for a game.

  • The_Decryptor@aussie.zone
    link
    fedilink
    English
    arrow-up
    10
    ·
    17 days ago

    For a game I don’t think it’s the end of the world, but you could end up in a situation where the first check passed, then you go to use the file and that fails, so you end up having to handle the “can’t use file” case twice anyway. But for something like showing a “Continue” menu item you obviously need to check that there’s an existing save to begin with before loading it.

    In general checking first leads to race conditions known as “time-of-check to time-of-use”, the pitfalls of which can vary greatly, but realistically aren’t a problem for a lot of cases.