1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "fileutils.h" |
6 | |
7 | #include <QDir> |
8 | |
9 | namespace Utils { |
10 | FileName::FileName() |
11 | { |
12 | |
13 | } |
14 | |
15 | FileName::FileName(const QFileInfo &info) |
16 | : QString(info.absoluteFilePath()) |
17 | { |
18 | } |
19 | |
20 | FileName FileName::fromUserInput(const QString &filename) |
21 | { |
22 | QString clean = QDir::cleanPath(filename); |
23 | if (clean.startsWith(QLatin1String("~/"))) |
24 | clean = QDir::homePath() + clean.mid(1); |
25 | return FileName(clean); |
26 | } |
27 | |
28 | const QString &FileName::toString() const |
29 | { |
30 | return *this; |
31 | } |
32 | |
33 | bool FileName::exists() const |
34 | { |
35 | return !isEmpty() && QFileInfo::exists(*this); |
36 | } |
37 | |
38 | FileName::FileName(const QString &string) |
39 | : QString(string) |
40 | { |
41 | |
42 | } |
43 | |
44 | } |
45 |