ofxDirList losses directory

If I have a loop that is call listDir() every so ofter to find new files after awhile the dirlist will say:

OF_ERROR: ofxDirList - error opening directory

has this happened to anyone else.

I put a addon on my google code that will stream files using dir list. I get the bug in there


After chatting with theo and doing some test I think it has been solved.

in ofxDirList if you call listDir(…) 2254 times the 2255 time you will get this errro:

{OPEN_MAX} file descriptors are currently open in the calling process.

Here are all the errors that opendir() will give you:

if(errno == EACCES) {  
		printf("Search permission is denied for the component of the path prefix of dirname or read permission is denied for dirname.\n");  
	if(errno == ELOOP) {  
		printf("A loop exists in symbolic links encountered during resolution of the dirname argument.\n");  
	if(errno == ENAMETOOLONG) {  
		printf("The length of the dirname argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.\n");  
	if(errno == ENOENT) {  
		printf("A component of dirname does not name an existing directory or dirname is an empty string.\n");  
	if(errno == ENOTDIR) {  
		printf("A component of dirname is not a directory.\n");  
	if(errno == ELOOP) {  
		printf("More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the dirname argument.\n");  
	if(errno == EMFILE) {  
		printf("{OPEN_MAX} file descriptors are currently open in the calling process.\n");  
	if(errno == ENAMETOOLONG) {  
		printf("As a result of encountering a symbolic link in resolution of the dirname argument, the length of the substituted pathname string exceeded {PATH_MAX}.\n");  
	if(errno == ENFILE) {  
		printf("Too many files are currently open in the system.\n");  

at the end of the while loop you need to add this:

if(dir != NULL) closedir(dir);  

It would be great is other people could try this. I think that it may only be a osx/unix bug but im not sure. try and run this and see what happens:

int count;  
ofxDirList DIR;  
count = 0;  
count ++;  
printf("Count:%i \n", count);  

I had exactly the same problem. My Application regularly rescans some directories to find changes. At a certain point it wasn’t able to read the contents of the directories and all the images that were loaded became white.

I put the code you mentioned in the file and then it worked.

if(dir != NULL) closedir(dir);  

A very annoying bug since it arises only after a couple of hours for me.

Is this already made into a bug-fix-request?

I just ran into this too, and noticing it has not yet been fixed I added an issue to github http://github.com/openframeworks/ofxDirList/issues/issue/3

Hey hat bug has been already reported and fixex;


The problem is you were looking at the ofxdirlist repp, that was created to migrate from svn but is not used anymore. The most updated code is in the addons folder of the main repo.

Ah, thanks Arturo :slight_smile: I was always confused about why there are multiple github repos, now I understand.