64,676
社区成员
发帖
与我相关
我的任务
分享
char path_buffer[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
errno_t err;
err = _makepath_s( path_buffer,_MAX_PATH, "E", "\\sample\\crt\\", "makepath", "c" ); // C4996
// Note: _makepath is deprecated; consider using _makepath_s instead
printf( "Path created with _makepath: %s\n\n", path_buffer );
printf("%d\n",err);
_splitpath_s( path_buffer, drive,_MAX_DRIVE, dir,_MAX_DIR, fname,_MAX_FNAME, ext,_MAX_EXT ); // C4996
// Note: _splitpath is deprecated; consider using _splitpath_s instead
printf( "Path extracted with _splitpath:\n" );
printf( " Drive: %s\n", drive );
printf( " Dir: %s\n", dir );
printf( " Filename: %s\n", fname );
printf( " Ext: %s\n", ext )
上面是我的测试代码?
int TFile::createdir(std::string npath)//创建文件夹
{
std::string newstdp=stdpath(npath);
if (stat(newstdp.c_str(),&info)==0)
{
return 0;
}
else
{
createdir(newstdp.substr(0,newstdp.find_last_of('\\')));
if(_mkdir(newstdp.c_str())!=0)
{
return 0;
}
}
return 1;
}
int TFile::createfile(std::string npath)//创建文件
{
std::string newstdp=stdpath(npath);
if (stat(newstdp.c_str(),&info)==0)
{
return 0;
}
createdir(newstdp.substr(0,newstdp.find_last_of('\\')));
FILE* iffop=fopen(newstdp.c_str(),"wb");
if(iffop==NULL)
{
return 0;
}
fclose(iffop);
return 1;
}