linux c 下获取文件大小

来源:互联网 发布:淘宝联盟靠谱吗 编辑:程序博客网 时间:2024/05/21 10:12

linux c 下获取文件大小


  1.  636 *       获取文件大小 
  2.  637 */  
  3.  638 int get_file_size(const char *filepath)  
  4.  639 {  
  5.  640         int filesize = 0;  
  6.  641         struct stat statbuff;  
  7.  642  
  8.  643         if (stat(filepath, &statbuff) < 0) {  
  9.  644                 return filesize;  
  10.  645         } else {  
  11.  646                 filesize = statbuff.st_size;  
  12.  647         }  
  13.  648  
  14.  649         return filesize;  
  15.  650 }  
0 0