论坛首页· 友情链接申请·申请版主· 广告投放· 道具中心· 设为首页· 收藏本站
发新话题
打印

[教程] 如何判断文件是否存在?

如何判断文件是否存在?

#include <sys/stat.h>
#include <io.h>

bool FileExist(const char* FileName)
{
    struct stat my_stat;
    return (stat(FileName, &my_stat) == 0);
}


bool IsDirectory(const char* FileName)
{
    struct stat my_stat;
    if (stat(FileName, &my_stat) != 0) return false;
    return ((my_stat.st_mode & S_IFDIR) != 0);
}
因为梦想而努力,因为有你而精彩!
mail: qianzongming@gmail.com

TOP

发新话题