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