【发布时间】:2012-09-29 14:57:23
【问题描述】:
我正在编写一些 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+");
}
}
感谢您提供的任何帮助。
【问题讨论】: