Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions application/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,34 +415,6 @@ bool Utils::isCoredumpctlExist()
return isCoredumpctlExist;
}

QString Utils::getHomePath(const QString &userName)
{
QString uName("");
if (!userName.isEmpty())
uName = userName;
else
uName = getCurrentUserName();

QString homePath = "";
if (isValidUserName(uName)) {
QProcess *unlock = new QProcess;
unlock->start("sh", QStringList() << "-c" << QString("cat /etc/passwd | grep %1").arg(uName));
unlock->waitForFinished();
auto output = unlock->readAllStandardOutput();
auto str = QString::fromUtf8(output);
homePath = str.mid(str.indexOf("::") + 2).split(":").first();
}

// 根据用户名获取家目录失败,默认采用QDir::homePath()作为homePath
QDir dir(homePath);
if (!dir.exists() || homePath.isEmpty())
homePath = QDir::homePath();

qCDebug(logUtils) << "userName: " << uName << "homePath:" << homePath;

return homePath;
}

QString Utils::appName(const QString &filePath)
{
QString ret;
Expand Down
3 changes: 1 addition & 2 deletions application/utils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -76,7 +76,6 @@ class Utils : public QObject
static QString getCurrentUserName();
static bool isValidUserName(const QString &userName);
static bool isCoredumpctlExist(); // is coredumpctl installed
static QString getHomePath(const QString &userName = "");
static QString appName(const QString &filePath);
static void resetToNormalAuth(const QString &path);
// 统计所有崩溃记录重复次数
Expand Down
Loading