I am working on some c code and am trying to programmatically create a directory. I found a while ago the mkdir(file, "w+) function to make the directory writable once its created but I've just noticed its creating a warning when compiled
warning: passing argument 2 of âmkdirâ makes integer from pointer without a cast
Below is the code I am using
void checkLogDirectoryExistsAndCreate()
{
struct stat st;
char logPath[FILE_PATH_BUF_LEN];
sprintf(logPath, "%s/logs", logRotateConfiguration->logFileDir);
if (stat(logPath, &st) != 0)
{
printf("Making log directory\n");
mkdir(logPath, "w+");
}
}
Thanks for any help you can provide.
According to this manpage, the 2nd parameter is a mode_t
, which is a numeric type and gives the wanted access mode of the directory. Here you should provide 0777
, an octal number meaning all of r
, w
and x
, and this is restricted by the umask
.
I don't know which of these informations apply to Windows.