2 ms·
Unless the input file is a device, and then you need to call: ioctl(STDIN_FILENO, BLKGETSIZE64, &size)
by rwmj 10y ago
Unless the input file is a device, and then you need to call:
ioctl(STDIN_FILENO, BLKGETSIZE64, &size)
- ithkuil 10y agoBut I guess this is orthogonal to where the file descriptor comes from (i.e. stdin or opening a file whose name is passed in the args)
- rwmj 10y agoIt's an orthogonal issue, yes, but calling stat or fstat on any block device whether from stdin or argv will return .st_size == 0, so your progress bar won't display the correct answers (or could display better answers if it used the ioctl).
- deleted 10y ago[deleted]