bool NewFileName(const char* filename)
{
size_t len;
if ( < (len = strlen(filename)))
{
char* tmpbuf, *p, c;
tmpbuf = (char*)malloc(len + );
strcpy_s(tmpbuf, len + , filename);
for (p = tmpbuf; *p; ++p)
{
if ('\\' != *p && '/' != *p)
{
continue;
}
c = *++p;
*p = '\0';
if ((_access(tmpbuf, )) != )
{
if ( != _mkdir(tmpbuf))
{
break;
}
}
*p = c;
}
{
FILE* file;
free(tmpbuf);
if ( == _tfopen_s(&file, filename, _T("a")))
{
fclose(file);
return true;
}
}
}
return false;
}
05-08 07:55