fix: improve installation permissions handling and file extension checking
This commit is contained in:
+2
-1
@@ -12,7 +12,8 @@ cmake -S "$path/.." -B "$path/../build" \
|
|||||||
cmake --build "$path/../build" --config Release -- -j"$(nproc)"
|
cmake --build "$path/../build" --config Release -- -j"$(nproc)"
|
||||||
|
|
||||||
if [ ! -w "$prefix" ] && [ "$(id -u)" -ne 0 ]; then
|
if [ ! -w "$prefix" ] && [ "$(id -u)" -ne 0 ]; then
|
||||||
sudo cmake --install "$path/../build" --config Release
|
echo "Elevated permissions are required to install to $prefix, enter root's password to continue."
|
||||||
|
su -m -c "cmake --install '$path/../build' --config Release" root
|
||||||
else
|
else
|
||||||
cmake --install "$path/../build" --config Release
|
cmake --install "$path/../build" --config Release
|
||||||
fi
|
fi
|
||||||
|
|||||||
+5
-7
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: Uyanide pywang0608@foxmail.com
|
* @Author: Uyanide pywang0608@foxmail.com
|
||||||
* @Date: 2025-11-30 20:59:57
|
* @Date: 2025-11-30 20:59:57
|
||||||
* @LastEditTime: 2026-01-15 06:00:51
|
* @LastEditTime: 2026-01-15 09:55:26
|
||||||
* @Description: THE utils header that every project needs :)
|
* @Description: THE utils header that every project needs :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QImageReader>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@@ -132,12 +133,9 @@ inline bool checkImageFile(const QString& filePath) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// check if valid extension
|
// check if valid extension
|
||||||
for (const QString& ext : validExtensions) {
|
static const QList<QByteArray> formats = QImageReader::supportedImageFormats();
|
||||||
if (filePath.endsWith(ext, Qt::CaseInsensitive)) {
|
QString ext = QFileInfo(filePath).suffix().toLower();
|
||||||
return true;
|
return formats.contains(ext.toUtf8());
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user