Getting the file size with os.stat() does not work with block devices.
You can now:
libray -i /dev/sg0 -o test.iso
Thanks! I've been too lazy to check if reading directly from disc even works or not, but I've had it in the back of my head for a while. Good to know it doesn't work. I'll merge this but I'll be changing it a little and then make a release after testing some.
I think the original intent with using os.stat() was to avoid using open() on an empty file. No need to open an empty file, IMO. There probably should have been checks where core.filesize was used that would quit if the file was empty. I see I've also used it inconsistently before and after using open().