#How do I check if a file exists?
17 messages · Page 1 of 1 (latest)
why do you want to know whether a file exists?
because if you're writing something like "if file exists then open it", which 99% of people do when they ask this question, that's a race condition
you can open it with a create if not already existing flag
that's a race condition, what if the file gets created in the time between you checking and creating it?
Options and flags which can be used to configure how a file is opened.
in this case it might be a bit silly, but stuff like this has been a cause of security vulns in the past
Options and flags which can be used to configure how a file is opened.
probably create_new
This is a cross-post of the official security advisory. The official advisory contains a signed version with our PG...
i mean, you can do what you want. I'm just pointing out it's bad form and better methods exist 😛