Re: [cc65] Re: readdir bug

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2012-09-17 20:17:35
Hi!

On Mon, Sep 17, 2012 at 08:08:01PM +0200, Spiro Trikaliotis wrote:
> I still see the possibility to have a function _readdir_restart() to
> call whenever there is file I/O after the readdir(). This way, the code
> can tell the readdir() code "reload the directory" by using seekdir().

Yes, good idea.

This would be a one-liner calling "seekdir (DIR, telldir (DIR))". I'm not sure
if the library should really supply such a function. It could be mentioned as
a possible workaround in the docs together with caching the list of entries in
dynamic memory.

> readdir() would be slowed down only by a test for a flag set in
> _readdir_restart() in the normal case. Only if it is set, there will be
> a penalty because seekdir() will be called internally.

But that would mean that a program using readdir will always get telldir and
seekdir linked in. I think it's better to have this decision placed on the
programmer. Many programs might not need additional code at all, others might
prefer a fast solution (building a linked list on the heap) and some may want
to use the solution you presented above.

> Another option: Read in the directory blocks one after the other, and
> process the directory entries on the cc65 side.

I'm really trying to avoid solutions like this. They create lots of code and
incompatibilities with several kind of hardware.
                                   
Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Sep 17 20:17:46 2012

This archive was generated by hypermail 2.1.8 : 2012-09-17 20:17:49 CEST