简体   繁体   中英

wxMkdir on Ubuntu

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM