forked from janbodnar/Qt5-Code-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_path.cpp
More file actions
33 lines (24 loc) · 837 Bytes
/
file_path.cpp
File metadata and controls
33 lines (24 loc) · 837 Bytes
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
#include <QTextStream>
#include <QFileInfo>
int main(int argc, char *argv[]) {
QTextStream out{stdout};
if (argc != 2) {
out << "Usage: file_times file" << endl;
return 1;
}
QString filename = argv[1];
QFileInfo fileinfo{filename};
QString absPath = fileinfo.absoluteFilePath();
QString baseName = fileinfo.baseName();
QString compBaseName = fileinfo.completeBaseName();
QString fileName = fileinfo.fileName();
QString suffix = fileinfo.suffix();
QString compSuffix = fileinfo.completeSuffix();
out << "Absolute file path: " << absPath << endl;
out << "Base name: " << baseName << endl;
out << "Complete base name: " << compBaseName << endl;
out << "File name: " << fileName << endl;
out << "Suffix: " << suffix << endl;
out << "Whole suffix: " << compSuffix << endl;
return 0;
}