QDir中mkdir和mkpath的区别!
mkdir:
原型:bool QDir::mkdir(const QString &dirName) const
Creates a sub-directory called dirName.
Returns true on success; otherwise returns false.
If the directory already exists when this function is called, it will return false.
解释:
创建一个名为dirName的子目录
成功:返回true;失败:返回false
如果此函数调用时,该目录已经存在,将会返回false
mkpath:
原型:bool QDir::mkpath(const QString &dirPath) const
Creates the directory path dirPath.
The function will create all parent directories necessary to create the directory.
Returns true if successful; otherwise returns false.
If the path already exists when this function is called, it will return true.
解释:
创建一个目录路径
这个函数将会创建所有必需的父类目录
成功:返回true;失败:返回false
如果此函数调用时,该路径已经存在,此函数将会返回true
区别:如果要创建的目录存在,mkdir返回false,而mkpath返回true,另外mkpath里为路径或者目录,而mkdir必须为目录!!!