Re: [AD] Splitting filesystem APIs |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
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;
> 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