ofDirectory: listDir:() source directory does not exist

Hi, All.

I met this error when run below code in OF.

[ error ] ofDirectory: listDir:() source directory does not exist: “”…/…/…/data/‎⁨/Users/onyx/Music/2020ProjectZ/cell0114Augmen0115/good/""
(lldb)

What’s wrong to me ?

void ofApp::scanDir(ofDirectory dir, vector & files)
{
dir.allowExt(“png”);
dir.listDir();
for(auto file : dir)
{
if(file.isDirectory())
{
scanDir(ofDirectory(file.getAbsolutePath()), files);
}
else
{
files.push_back(file);
}
}
}
//--------------------------------------------------------------
void ofApp::setup(){
k=0;
ofDirectory dir (“‎⁨/Users/onyx/Music/2020ProjectZ/cell0114Augmen0115/good/”);
scanDir(dir, files); // look for videos here!}
}

Thanks in advance.
Best,
from @bemoregt.

AFAIK ofDirectory needs a drive letter ie (c:\) otherwise thinks the path is relative to your project. I always do the following for absolute paths:

ofDisableDataPath(); // disable relative paths

ofDirectory dir (<absolute path including drive letter>);

ofEnableDataPath(); // re enable relative paths 

1 Like