I try to use wxMkdir function to create a new directory in my c++ program. The directory
/home/test/Documents/MATLAB/mydata/demo
already exists. But the following code
wxString dataDirectory = wxT("/home/test/Documents/MATLAB/mydata/demo/A");
if(! wxDirExists(dataDirectory))
{
wxMkdir(dataDirectory);
}
will pop up a runtime error dialog saying that
Directory '/home/test/Documents/MATLAB/mydata/demo/A' couldn't be created (error2: No such file or directory)
and the directory A
under directory demo
will not be created. However, if I change the desired directory to /home/test/Documents/MATLAB/mydata/A
, everything works.
So is there a maximum directory depth for wxMkdir in the Ubuntu implementation of wxWidgets? This problem is not seen under Mac, however. I searched the web and couldn't get anything meaningful. Anyone has a better idea?
If mkdir
fails with a "No such file or directory" error, it usually means that the parent directory doesn't exist (or is a dangling symlink). Presumably the same would apply to wxMkdir
.
Does /home/test/Documents/MATLAB/mydata/demo
already exist? And just to be sure, is it a directory?
(If that's not the problem, I'll delete this answer and add it as a comment.)