Skip to content

What's the best way to determine if a file already exists? #24

Answered by Tuxera-TonyQ
Tuxera-TonyQ asked this question in Q&A
Discussion options

You must be logged in to vote

Our engineers have suggested that you consider using red_open() without the RED_O_CREAT flag. If the file exists, it succeeds; if the file does not exist, it fails with the RED_ENOENT errno.

Also note:
If the file is already open, opening it again would open another independent file descriptor, and if that file descriptor is unneeded, it can be closed (which wouldn't affect other file descriptors for the same file).

Replies: 1 comment

Comment options

Tuxera-TonyQ
Feb 10, 2023
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by Tuxera-TonyQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant