Reputation: 1098
Is there a means to check if a file exists, avoiding any potential race conditions, while not reading the file into memory?
I've seen examples using try/catch to avoid race conditions, but they all read the file into memory with something like:
with open filename as file
I have a large file (roughly 100mb) that I need to check the existence of, but for security's sake, would like to avoid creating a race condition while checking. Reading the entire file into memory is impractical. What am I not thinking of?
I'm new, be gentle.
Upvotes: 1
Views: 565
Reputation: 798526
The entire purpose of race condition avoidance is strictly so that the file being opened is the file that was checked for. Trying to have one without the other is a non sequitur.
Also, open()
doesn't read the file into memory, so that part of the question doesn't even make sense to begin with.
Upvotes: 1