怎样判断一个文件是否为空
2011-07-28 17:15
363 查看
BOOL HDTLog4Cplus::IsLogFileEmpty ()
{
FILE* fp = NULL ;
if((fp = fopen (m_filename.c_str(), "rb")) == NULL )
{
return FALSE ;
}
fseek (fp, 0, SEEK_END) ;
int lenth = ftell (fp) ;
if (0 == lenth)
{
fclose (fp) ;
return TRUE ;
}
else if (-1 == lenth)
{
throw runtime_error ("参数输入错") ;
}
else
{
fclose (fp) ;
return FALSE ;
}
}
{
FILE* fp = NULL ;
if((fp = fopen (m_filename.c_str(), "rb")) == NULL )
{
return FALSE ;
}
fseek (fp, 0, SEEK_END) ;
int lenth = ftell (fp) ;
if (0 == lenth)
{
fclose (fp) ;
return TRUE ;
}
else if (-1 == lenth)
{
throw runtime_error ("参数输入错") ;
}
else
{
fclose (fp) ;
return FALSE ;
}
}
相关文章推荐
- 怎样判断一个盘上是否有文件
- 批处理怎样判断一个txt文件是否为空?
- 怎样使用 Python 来判断一个路径是否存在判断一个路径是文件还是目录
- 怎样判断一个盘上是否有文件
- Java中怎样判断一个字符串是否是数字
- Linux下怎样判断一个binary是否可以debug
- 怎样快速判断一个数组中,和值(任意1个或几个的和) 是否等于某值:
- linux判断一个文件是否存在
- 判断某一个路径下某个资源文件是否存在
- 判断一个文件是否可以使用
- 判断一个文件格式是否是日期格式
- 判断一个文件是否存在
- 判断一个文件是否存在
- 【shell】判断一个文件或者目录是否存在
- Java中怎样判断一个字符串是否是数字
- php怎样判断一个字符串是否包含另一个字符串?
- 怎样判断一个股权众筹项目是否靠谱?
- Lua判断一个目录或文件是否存在的方法
- C++基础:怎样判断某一文件是否存在
- 判断一个文件是否正在被使用