Actually, that's not completley true. pv will detect the file size if you use the shell to read a file into it, like pv < file.
But I guess they do...
http://stackoverflow.com/questions/1734243/in-c-how-do-i-pri...
I've seen that kind of brokenness from programs trying to find their binary image on disk. Don't do it, it's bad.
ioctl(STDIN_FILENO, BLKGETSIZE64, &size)It's not the same thing as trying to walk the FS to look for the filename is silly.
pv file.bin | dd of=/dev/sdb
is nice too. Honestly while the OP sparks a nice conversation, it is actually complaining about the use of dd out of lack of knowledge.