简体   繁体   English

在Ubuntu上的wxMkdir

[英]wxMkdir on Ubuntu

I try to use wxMkdir function to create a new directory in my c++ program. 我尝试使用wxMkdir函数在我的c ++程序中创建一个新目录。 The directory /home/test/Documents/MATLAB/mydata/demo already exists. 目录/home/test/Documents/MATLAB/mydata/demo已存在。 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) 无法创建目录“ / home / test / Documents / MATLAB / mydata / demo / A”(错误2:无此类文件或目录)

and the directory A under directory demo will not be created. 并且不会创建目录demo下的目录A However, if I change the desired directory to /home/test/Documents/MATLAB/mydata/A , everything works. 但是,如果我将所需的目录更改为/home/test/Documents/MATLAB/mydata/A ,则一切正常。

So is there a maximum directory depth for wxMkdir in the Ubuntu implementation of wxWidgets? 那么在wxWidgets的Ubuntu实现中wxMkdir的目录深度最大吗? This problem is not seen under Mac, however. 但是,在Mac下看不到此问题。 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). 如果mkdir失败并显示“没有这样的文件或目录”错误,则通常表示父目录不存在(或是悬空的符号链接)。 Presumably the same would apply to wxMkdir . 大概对wxMkdir同样适用。

Does /home/test/Documents/MATLAB/mydata/demo already exist? /home/test/Documents/MATLAB/mydata/demo已经存在? 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.) (如果这不是问题,我将删除此答案并将其添加为评论。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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