On 15.07.20 17:54, Alan DeKok wrote:
On Jul 15, 2020, at 11:49 AM, Sven Hartge <sven@svenhartge.de> wrote:
OK, please see the attached diff.
Nothing was attached. :(
Yes, the listmanager ate it. See my other mail. But based on your tests with scandir() it will not be useful.
Please note that I have no idea what I am doing, this may be memleaky as hell (although I think I added the free(namelist) to the correct places) and is not tested in any way.
I just adapted the example code from the scandir(3) man-page and massaged it a bit to fit the existing code.
Also note: if one uses scandir one could technically use its own filter to remove '.' and '..' from the list of entries but I wanted to change to be as minimal as possible.
Sure. The larger issue is that I tested it on OSX, and scandir() returns *duplicates*. i.e. it seems to randomly return the same file multiple times. So that's useless.
What? That is beyond useless, that is broken.
Quite frankly, it's not a lot more code to just readdir() the entire directory, and put the files into an ordered heap. The "read file" code can then just pop entries from the heap.
Well, that here is the moment I step of the train, that is way past my abilities, sorry. Grüße, Sven.