Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/kxftconfig.cpp
Show All 24 Lines | |||||
25 | #include <math.h> | 25 | #include <math.h> | ||
26 | #include <string.h> | 26 | #include <string.h> | ||
27 | #include <ctype.h> | 27 | #include <ctype.h> | ||
28 | #include <stdlib.h> | 28 | #include <stdlib.h> | ||
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> | ||
30 | 30 | | |||
31 | #include <QRegExp> | 31 | #include <QRegExp> | ||
32 | #include <QFile> | 32 | #include <QFile> | ||
33 | #include <QFileInfo> | ||||
33 | #include <QDir> | 34 | #include <QDir> | ||
34 | #include <QX11Info> | 35 | #include <QX11Info> | ||
35 | #include <QByteArray> | 36 | #include <QByteArray> | ||
36 | #include <QDebug> | 37 | #include <QDebug> | ||
37 | 38 | | |||
38 | #include <KLocalizedString> | 39 | #include <KLocalizedString> | ||
39 | #include <kde_file.h> | | |||
40 | #include <KGlobal> | 40 | #include <KGlobal> | ||
41 | #include <KStandardDirs> | 41 | #include <KStandardDirs> | ||
42 | 42 | | |||
43 | #include <fontconfig/fontconfig.h> | 43 | #include <fontconfig/fontconfig.h> | ||
44 | 44 | | |||
45 | using namespace std; | 45 | using namespace std; | ||
46 | 46 | | |||
47 | static int point2Pixel(double point) | 47 | static int point2Pixel(double point) | ||
Show All 25 Lines | 64 | if (!d.isNull()) { | |||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | return ds; | 75 | return ds; | ||
76 | } | 76 | } | ||
77 | 77 | | |||
78 | return d; | 78 | return d; | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | static bool check(const QString &path, unsigned int fmt, bool checkW = false) | | |||
82 | { | | |||
83 | KDE_struct_stat info; | | |||
84 | QByteArray pathC(QFile::encodeName(path)); | | |||
85 | | ||||
86 | return 0 == KDE_lstat(pathC, &info) && (info.st_mode & S_IFMT) == fmt && | | |||
87 | (!checkW || 0 ==::access(pathC, W_OK)); | | |||
88 | } | | |||
89 | | ||||
90 | inline bool fExists(const QString &p) | 81 | inline bool fExists(const QString &p) | ||
91 | { | 82 | { | ||
92 | return check(p, S_IFREG, false); | 83 | return QFileInfo(p).isFile(); | ||
93 | } | 84 | } | ||
94 | 85 | | |||
95 | inline bool dWritable(const QString &p) | 86 | inline bool dWritable(const QString &p) | ||
96 | { | 87 | { | ||
97 | return check(p, S_IFDIR, true); | 88 | QFileInfo info(p); | ||
89 | return info.isDir() && info.isWritable(); | ||||
98 | } | 90 | } | ||
99 | 91 | | |||
100 | static QString getDir(const QString &f) | 92 | static QString getDir(const QString &f) | ||
101 | { | 93 | { | ||
102 | QString d(f); | 94 | QString d(f); | ||
103 | 95 | | |||
104 | int slashPos = d.lastIndexOf('/'); | 96 | int slashPos = d.lastIndexOf('/'); | ||
105 | 97 | | |||
106 | if (-1 != slashPos) { | 98 | if (-1 != slashPos) { | ||
107 | d.remove(slashPos + 1, d.length()); | 99 | d.remove(slashPos + 1, d.length()); | ||
108 | } | 100 | } | ||
109 | 101 | | |||
110 | return dirSyntax(d); | 102 | return dirSyntax(d); | ||
111 | } | 103 | } | ||
112 | 104 | | |||
113 | static time_t getTimeStamp(const QString &item) | 105 | static QDateTime getTimeStamp(const QString &item) | ||
114 | { | 106 | { | ||
115 | KDE_struct_stat info; | 107 | return QFileInfo(item).lastModified(); | ||
116 | | ||||
117 | return !item.isNull() && 0 == KDE_lstat(QFile::encodeName(item), &info) ? info.st_mtime : 0; | | |||
118 | } | 108 | } | ||
119 | 109 | | |||
120 | // | 110 | // | ||
121 | // Obtain location of config file to use. | 111 | // Obtain location of config file to use. | ||
122 | QString getConfigFile() | 112 | QString getConfigFile() | ||
123 | { | 113 | { | ||
124 | FcStrList *list = FcConfigGetConfigFiles(FcConfigGetCurrent()); | 114 | FcStrList *list = FcConfigGetConfigFiles(FcConfigGetCurrent()); | ||
125 | QStringList files; | 115 | QStringList files; | ||
▲ Show 20 Lines • Show All 712 Lines • Show Last 20 Lines |