On 09/20/12 05:10, Roman Kantor wrote:
> On 20/09/2012 11:27, MacArthur, Ian (SELEX GALILEO, UK) wrote:
>>
>> Could do - though I'm a big fan of just calling access() on the path
>> before I try to use it - that pretty quickly filters out any mistakes...!
>> [..]
>
> Yeah, I use access too - actually utf-8 version fl_access() in fl_utf8.h ;)
> Also in such cases Fl_Shared_Image::get() seems to be more appropriate which
> constructs image on the heap and returns 0 pointer if it fails?
So it sounds like you guys use access() to do these tests.
Should we add a recommendation in the docs and examples to use access()
to test this, or would it be better to improve the API?
Kinda seeking a vote, as this issue has come up with new users many
times before, and I'd just like to see if we can solve it by improving
the docs/examples.
When left to my own devices, I usually include two methods for a
class whose ctor might fail: fail() and fail_msg(), ie:
if ( jpg->fail() ) // class failed?
fl_alert(jpg->fail_msg()); // get human readable error
This way specific errors could be returned (e.g. "bad header", "unknown
file format")
vs. a file access error (e.g. "/path/foo.png: permission denied")
fail_msg() could return a string internally managed by the class;
dynamically allocated, and later freed by the dtor.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk