我正在处理一些C语言代码,尝试以编程方式创建一个文件夹。我之前找到了mkdir(file, "w+")函数来创建一个可写的目录,但是我刚刚发现在编译时会产生警告。
warning: passing argument 2 of âmkdirâ makes integer from pointer without a cast
以下是我使用的代码
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+");
}
}
感谢您提供的任何帮助。