Verified Commit a1b63b68 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/image: Add findSymlinkTarget()

This helps find the real file path.
parent ce6dbf90
/*
SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef FINDSYMLINKTARGET_H
#define FINDSYMLINKTARGET_H
#include <QFileInfo>
static QString findSymlinkTarget(const QFileInfo &info)
{
if (!info.isSymLink()) {
return info.filePath();
}
int count = 0;
QString target = info.symLinkTarget();
while (count < 10 && QFileInfo(target).isSymLink()) {
target = info.symLinkTarget();
count += 1;
}
if (QFileInfo(target).isSymLink()) {
return QString();
}
return target;
}
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment