您的位置:首页 > 其它

怎样判断一个文件是否为空

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 ;

  }

 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  fp null file