部分GNU代码片 14、获取文件长度的两种方法 fopen open

pf = fopen(file, "r");
    if (!pf)
    {
        cout<<"Couldn't open file:"<< file <        return FILE_OPEN_ERROR;
    }
    struct stat statBuf;
    stat(file, &statBuf);
   
    //如果是没有数据的"空文件",时间则为昨天
    //否则,是文件记录的时间

    cout << "Size of this file is: "<   
    if ( 0 == statBuf.st_size )
    {
        return 0;//空文件直接返回
    } 

 

 

dst_fd = open(dst_filename, O_CREAT | O_RDWR | O_LARGEFILE, 0666);
 src_fd = open(src_filename, O_RDONLY | O_LARGEFILE, 0666);
 if(dst_fd < 0 || src_fd < 0)
 {
  ret = -1;
  goto __end;
 }

 src_size = (unsigned long long)lseek64(src_fd, 0, SEEK_END);
 dst_size = (unsigned long long)lseek64(dst_fd, 0, SEEK_END);

 

你可能感兴趣的:(linux,dst,file,struct)