-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpath.cpp
More file actions
158 lines (130 loc) · 2.88 KB
/
Copy pathpath.cpp
File metadata and controls
158 lines (130 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include "common/framework.h"
#include "common/alias.h"
#include "common/path.h"
#include "common/logs.h"
#include "common/private/path_p.h"
#include "qcoreapplication.h"
namespace shelllet {
namespace common {
std::ostream& operator<<(std::ostream& o, const Path& p)
{
o << p.d_func()->path;
return o;
}
}
}
using namespace shelllet::common;
shelllet::common::Path::Path(PathPrivate& d)
: Object(d, nullptr)
{
}
shelllet::common::Path::Path(const char* path)
: Path(*new PathPrivate)
{
Q_D(Path);
d->path = path;
}
shelllet::common::Path::Path(const std::string& path)
: Path(*new PathPrivate)
{
Q_D(Path);
d->path = path;
}
shelllet::common::Path::Path(const std::filesystem::path& path)
: Path(*new PathPrivate)
{
Q_D(Path);
d->path = path;
}
shelllet::common::Path::Path()
: Path(*new PathPrivate)
{
}
shelllet::common::Path& shelllet::common::Path::operator=(const Path& p)
{
Q_D(Path);
d->path = p.d_func()->path;
return *this;
}
shelllet::common::Path::Path(const Path& p)
: Path(*new PathPrivate)
{
Q_D(Path);
d->path = p.d_func()->path;
}
shelllet::common::Path& shelllet::common::Path::operator/=(const Path& path)
{
Q_D(Path);
d->path /= path.d_func()->path;
return *this;
}
void shelllet::common::Path::replaceExtension(const Path& path)
{
Q_D(Path);
d->path.replace_extension(path.d_func()->path);
}
void shelllet::common::Path::replaceFileName(const Path& path)
{
Q_D(Path);
d->path.replace_filename(path.d_func()->path);
}
shelllet::common::String shelllet::common::Path::fileName() const
{
Q_D(const Path);
return d->path.stem().string();
}
shelllet::common::Path shelllet::common::Path::operator/(const char* path) const
{
Q_D(const Path);
return d->path / path;
}
shelllet::common::Path shelllet::common::Path::operator/(const Path& path) const
{
Q_D(const Path);
return d->path / path.d_func()->path;
}
shelllet::common::String shelllet::common::Path::toString() const
{
Q_D(const Path);
return d->path.string();
}
bool shelllet::common::Path::isExist() const
{
Q_D(const Path);
return std::filesystem::exists(d->path);
}
bool shelllet::common::Path::isEmpty() const
{
Q_D(const Path);
return d->path.empty();
}
bool shelllet::common::Path::isDir() const
{
Q_D(const Path);
return std::filesystem::is_directory(d->path);
}
shelllet::common::String shelllet::common::Path::extension() const
{
Q_D(const Path);
return d->path.extension().string();
}
shelllet::common::Path shelllet::common::Path::applicationDirPath()
{
return String::fromQString(&static_cast<const QString&>(QCoreApplication::applicationDirPath())) ;
}
std::filesystem::path shelllet::common::Path::toStdPath() const
{
Q_D(const Path);
return d->path;
}
shelllet::common::Path::Path(const String& path)
: Path(*new PathPrivate)
{
Q_D(Path);
d->path = path.toStdString();
}
shelllet::common::Path::operator std::filesystem::path() const
{
Q_D(const Path);
return d->path;
}