I want to write a program that checks for the existence of a directory; if that directory does not exist then it creates the directory and a log file inside of it, but if the directory already exists, then it just creates a new log file in that folder.
How would I do this in C with Linux?
Look at
statfor checking if the directory exists,And
mkdir, to create a directory.You can see the manual of these functions with the
man 2 statandman 2 mkdircommands.