linux c 得到文件大小

#include <sys/stat.h>

unsigned long get_file_size(const char *path)
{
  unsigned long filesize = -1;
  struct stat statbuff;
  if(stat(path, &statbuff) < 0){
    return filesize;
  }else{
    filesize = statbuff.st_size;
  }
  return filesize;
}

posted on 2014-04-19 10:56  小风儿_xf  阅读(193)  评论(0编辑  收藏  举报

导航