Re: [AD] Splitting filesystem APIs |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sun April 19 2009, Peter Wang wrote:
> On 2009-04-19, Thomas Fjellstrom <tfjellstrom@xxxxxxxxxx> wrote:
> > On Sun April 19 2009, Peter Wang wrote:
> > > or more realistically,
> > >
> > > next = al_readdir(entry);
> > > if (!next)
> > > break;
> > > filename = al_path_to_string(al_get_entry_name(next), '/');
> > > al_load_bitmap(filename, "bmp");
> > > al_destroy_entry(next);
> > >
> > > The calls to al_open_entry/al_fopen and al_close_entry/al_fclose
> > > correspond exactly! There is some ugliness because right now
> > > al_get_entry_name() happens to return an ALLEGRO_PATH instead of a
> > > string, but that's easily solved. Basically, no real impact either way.
> >
> > Except once you split the two types, you can't return any kind of handle
> > from readdir, remember it can return files and directories. What exactly
> > is it returning in your code examples?
>
> ALLEGRO_FS_ENTRY still returns stat information about both files and
> directories. I left out the part where you check the file criteria to
> see if you want to load it:
>
> next = al_readdir(entry);
> if (!next)
> break;
> if (!al_is_file(next))
> continue;
So we're back to something I chucked out ages ago? (that being a separate
FILE, DIR and STAT types). but you know what, I don't really care anymore. If
you like this sort of thing, do it. Just make sure it works ::)
> > Also your code is rather less realistic than you'd like to think. If you
> > already have a handle, whats the point in using a second one via
> > al_load_bitmap?
>
> Already explained this. It's clearer and less error prone.
>
> > Now add some actual logic to your code to handle all the
> > errors, and that loading code is probably going to want to look at the
> > stat info.
>
> Like what? Please show a concrete example.
>
> Peter
>
>
> ---------------------------------------------------------------------------
>--- Stay on top of everything new and different, both inside and
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today.
> Use priority code J9JMT32. http://p.sf.net/sfu/p
--
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx