bool DirMake(const QString &path)
{
QString full_path = GetFullPath(path);
QDir dir(full_path);
if (dir.exists())
{
return true;
}
else
{
return dir.mkpath(full_path);
}
// QDir *folder = new QDir;
// bool exist = folder->exists(path);
// if(exist)
// {
// qWarning() <<"Dir is already existed!!";
// return true;
// }
// else
// {
// //创建文件夹
// return folder->mkdir(path);
// }
}
///
/// \brief 删除目录并删除数据库中文件信息
/// \param 目录名
/// \return 结果
///
bool DirRemove(const QString &path)
{
if (path.isEmpty())
{
qWarning() << "the path is empty error! ";
return false;
}
QDir dir(path);
return dir.removeRecursively();
}
QString GetFullPath(const QString &path)
{
QFileInfo file_info(path);
return file_info.absoluteFilePath();
}
QT删除及创建文件夹
最新推荐文章于 2024-04-26 11:47:52 发布