3 ms·
GNOME's GIO library has a function that reads all requested bytes in a single call, until EOF or an error condition is reached: https://developer.gnome.org/gio/
by rzzzt 5y ago
GNOME's GIO library has a function that reads all requested bytes in a single call, until EOF or an error condition is reached: https://developer.gnome.org/gio/stable/GInputStream.html#g-input-stream-read-all https://developer.gnome.org/gio/stable/GInputStream.html#g-i...
- azinman2 5y agoBut don't you still need to switch on all of the possible errors to figure out what to do? I guess I'm thinking about something that's more like a strategy that you tell the system. E.g. if it's retryable, so do this many times or up to this many seconds. If it's not possible to write (out of space, device no longer exists, internet is down), then hand me back a string I can display to my user about the error. Etc. Something that is more akin to all the cases that you'd have to handle being done inside of a library call, with easy predictable ways to work with very few possible error(s) that get returned.
- rzzzt 5y agoIt could certainly be taken further along these lines; I was mentioning it because of the "short read" scenario, which is... not quite an error, but can be the cause of one, as st_goliath writes above.