douzhang3822 2016-11-24 22:53
浏览 127
已采纳

在GO中获取实际文件大小与表观大小

"fs.sys.Size" (fs being fileStat in the os package) returns the apparent size of a file. This isn't ideal when dealing with sparse files.

Is there a way to get the actual file size in GO? Or all applications are bound to get the converted metadata that represent empty blocks as real ones?

  • 写回答

1条回答 默认 最新

  • dongwang788787 2016-11-25 15:16
    关注

    Looks like the Stat_t structure filled using stat/fstat calls from the Syscall package is all you need. Just multiply Blocks by 512 to get the disk space consumed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大