QDir中mkdir和mkpath的区别

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必须为目录!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值