Changeset View
Changeset View
Standalone View
Standalone View
krArc/krarc.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 55 | #ifdef KRARC_ENABLED | |||
---|---|---|---|---|---|
66 | * 3. KrArcCodec maps 0xE000-0xE0FF to 0x0000-0x00FF, while calls the default encoding routine | 66 | * 3. KrArcCodec maps 0xE000-0xE0FF to 0x0000-0x00FF, while calls the default encoding routine | ||
67 | * for other unicodes. | 67 | * for other unicodes. | ||
68 | */ | 68 | */ | ||
69 | 69 | | |||
70 | class KrArcCodec : public QTextCodec | 70 | class KrArcCodec : public QTextCodec | ||
71 | { | 71 | { | ||
72 | public: | 72 | public: | ||
73 | KrArcCodec(QTextCodec * codec) : originalCodec(codec) {} | 73 | KrArcCodec(QTextCodec * codec) : originalCodec(codec) {} | ||
74 | virtual ~KrArcCodec() {} | 74 | ~KrArcCodec() override = default; | ||
nmel: Q_DECL_OVERRIDE here and other places or we are moving to direct `override` across the board as… | |||||
Maybe I do not understand the question but why not? C++11 is mandatory for a long time now and you added override to krusader/icon.cpp yourself. abika: Maybe I do not understand the question but why not? C++11 is mandatory for a long time now and… | |||||
Just wanted to confirm. I forgot that I switched to plain override myself. ;) nmel: Just wanted to confirm. I forgot that I switched to plain override myself. ;) | |||||
75 | 75 | | |||
76 | virtual QByteArray name() const Q_DECL_OVERRIDE { | 76 | QByteArray name() const Q_DECL_OVERRIDE { | ||
77 | return originalCodec->name(); | 77 | return originalCodec->name(); | ||
78 | } | 78 | } | ||
79 | virtual QList<QByteArray> aliases() const Q_DECL_OVERRIDE { | 79 | QList<QByteArray> aliases() const Q_DECL_OVERRIDE { | ||
80 | return originalCodec->aliases(); | 80 | return originalCodec->aliases(); | ||
81 | } | 81 | } | ||
82 | virtual int mibEnum() const Q_DECL_OVERRIDE { | 82 | int mibEnum() const Q_DECL_OVERRIDE { | ||
83 | return originalCodec->mibEnum(); | 83 | return originalCodec->mibEnum(); | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | protected: | 86 | protected: | ||
87 | virtual QString convertToUnicode(const char *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { | 87 | QString convertToUnicode(const char *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { | ||
88 | return originalCodec->toUnicode(in, length, state); | 88 | return originalCodec->toUnicode(in, length, state); | ||
89 | } | 89 | } | ||
90 | virtual QByteArray convertFromUnicode(const QChar *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { | 90 | QByteArray convertFromUnicode(const QChar *in, int length, ConverterState *state) const Q_DECL_OVERRIDE { | ||
91 | // the QByteArray is embedded into the unicode charset (QProcess hell) | 91 | // the QByteArray is embedded into the unicode charset (QProcess hell) | ||
92 | QByteArray result; | 92 | QByteArray result; | ||
93 | for (int i = 0; i != length; i++) { | 93 | for (int i = 0; i != length; i++) { | ||
94 | if (((in[ i ].unicode()) & 0xFF00) == 0xE000) // map 0xE000-0xE0FF to 0x0000-0x00FF | 94 | if (((in[ i ].unicode()) & 0xFF00) == 0xE000) // map 0xE000-0xE0FF to 0x0000-0x00FF | ||
95 | result.append((char)(in[ i ].unicode() & 0xFF)); | 95 | result.append((char)(in[ i ].unicode() & 0xFF)); | ||
96 | else | 96 | else | ||
97 | result.append(originalCodec->fromUnicode(in + i, 1, state)); | 97 | result.append(originalCodec->fromUnicode(in + i, 1, state)); | ||
98 | } | 98 | } | ||
Show All 35 Lines | 131 | #endif | |||
134 | 134 | | |||
135 | return 0; | 135 | return 0; | ||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | } // extern "C" | 138 | } // extern "C" | ||
139 | 139 | | |||
140 | #ifdef KRARC_ENABLED | 140 | #ifdef KRARC_ENABLED | ||
141 | kio_krarcProtocol::kio_krarcProtocol(const QByteArray &pool_socket, const QByteArray &app_socket) | 141 | kio_krarcProtocol::kio_krarcProtocol(const QByteArray &pool_socket, const QByteArray &app_socket) | ||
142 | : SlaveBase("kio_krarc", pool_socket, app_socket), archiveChanged(true), arcFile(0L), extArcReady(false), | 142 | : SlaveBase("kio_krarc", pool_socket, app_socket), archiveChanged(true), arcFile(nullptr), extArcReady(false), | ||
143 | password(QString()), krConf("krusaderrc"), codec(0) | 143 | password(QString()), krConf("krusaderrc"), codec(nullptr) | ||
144 | { | 144 | { | ||
145 | KRFUNC; | 145 | KRFUNC; | ||
146 | confGrp = KConfigGroup(&krConf, "Dependencies"); | 146 | confGrp = KConfigGroup(&krConf, "Dependencies"); | ||
147 | 147 | | |||
148 | KConfigGroup group(&krConf, "General"); | 148 | KConfigGroup group(&krConf, "General"); | ||
149 | QString tmpDirPath = group.readEntry("Temp Directory", _TempDirectory); | 149 | QString tmpDirPath = group.readEntry("Temp Directory", _TempDirectory); | ||
150 | QDir tmpDir(tmpDirPath); | 150 | QDir tmpDir(tmpDirPath); | ||
151 | if(!tmpDir.exists()) { | 151 | if(!tmpDir.exists()) { | ||
Show All 36 Lines | 187 | i18n("krarc: write support is disabled.\n" | |||
188 | "You can enable it on the 'Archives' page in Konfigurator.")); | 188 | "You can enable it on the 'Archives' page in Konfigurator.")); | ||
189 | return false; | 189 | return false; | ||
190 | } | 190 | } | ||
191 | } | 191 | } | ||
192 | 192 | | |||
193 | void kio_krarcProtocol::receivedData(KProcess *, QByteArray &d) | 193 | void kio_krarcProtocol::receivedData(KProcess *, QByteArray &d) | ||
194 | { | 194 | { | ||
195 | KRFUNC; | 195 | KRFUNC; | ||
196 | QByteArray buf(d); | 196 | const QByteArray& buf(d); | ||
197 | data(buf); | 197 | data(buf); | ||
198 | processedSize(d.length()); | 198 | processedSize(d.length()); | ||
199 | decompressedLen += d.length(); | 199 | decompressedLen += d.length(); | ||
200 | } | 200 | } | ||
201 | 201 | | |||
202 | void kio_krarcProtocol::mkdir(const QUrl &url, int permissions) | 202 | void kio_krarcProtocol::mkdir(const QUrl &url, int permissions) | ||
203 | { | 203 | { | ||
204 | KRFUNC; | 204 | KRFUNC; | ||
▲ Show 20 Lines • Show All 665 Lines • ▼ Show 20 Line(s) | 828 | { | |||
870 | finished(); | 870 | finished(); | ||
871 | } | 871 | } | ||
872 | 872 | | |||
873 | bool kio_krarcProtocol::setArcFile(const QUrl &url) | 873 | bool kio_krarcProtocol::setArcFile(const QUrl &url) | ||
874 | { | 874 | { | ||
875 | KRFUNC; | 875 | KRFUNC; | ||
876 | KRDEBUG(url.fileName()); | 876 | KRDEBUG(url.fileName()); | ||
877 | QString path = getPath(url); | 877 | QString path = getPath(url); | ||
878 | time_t currTime = time(0); | 878 | time_t currTime = time(nullptr); | ||
879 | archiveChanged = true; | 879 | archiveChanged = true; | ||
880 | newArchiveURL = true; | 880 | newArchiveURL = true; | ||
881 | // is the file already set ? | 881 | // is the file already set ? | ||
882 | if (arcFile && getPath(arcFile->url(), QUrl::StripTrailingSlash) == path.left(getPath(arcFile->url(), QUrl::StripTrailingSlash).length())) { | 882 | if (arcFile && getPath(arcFile->url(), QUrl::StripTrailingSlash) == path.left(getPath(arcFile->url(), QUrl::StripTrailingSlash).length())) { | ||
883 | newArchiveURL = false; | 883 | newArchiveURL = false; | ||
884 | // Has it changed ? | 884 | // Has it changed ? | ||
885 | KFileItem* newArcFile = new KFileItem(arcFile->url(), QString(), arcFile->mode()); | 885 | KFileItem* newArcFile = new KFileItem(arcFile->url(), QString(), arcFile->mode()); | ||
886 | if (metaData("Charset") != currentCharset || !newArcFile->cmp(*arcFile)) { | 886 | if (metaData("Charset") != currentCharset || !newArcFile->cmp(*arcFile)) { | ||
887 | currentCharset = metaData("Charset"); | 887 | currentCharset = metaData("Charset"); | ||
888 | 888 | | |||
889 | codec = QTextCodec::codecForName(currentCharset.toLatin1()); | 889 | codec = QTextCodec::codecForName(currentCharset.toLatin1()); | ||
890 | if (codec == 0) | 890 | if (codec == nullptr) | ||
891 | codec = QTextCodec::codecForMib(4 /* latin-1 */); | 891 | codec = QTextCodec::codecForMib(4 /* latin-1 */); | ||
892 | 892 | | |||
893 | delete arcFile; | 893 | delete arcFile; | ||
894 | password.clear(); | 894 | password.clear(); | ||
895 | extArcReady = false; | 895 | extArcReady = false; | ||
896 | arcFile = newArcFile; | 896 | arcFile = newArcFile; | ||
897 | } else { // same old file | 897 | } else { // same old file | ||
898 | delete newArcFile; | 898 | delete newArcFile; | ||
899 | archiveChanged = false; | 899 | archiveChanged = false; | ||
900 | if (encrypted && password.isNull()) | 900 | if (encrypted && password.isNull()) | ||
901 | initArcParameters(); | 901 | initArcParameters(); | ||
902 | } | 902 | } | ||
903 | } else { // it's a new file... | 903 | } else { // it's a new file... | ||
904 | extArcReady = false; | 904 | extArcReady = false; | ||
905 | 905 | | |||
906 | // new archive file means new dirDict, too | 906 | // new archive file means new dirDict, too | ||
907 | dirDict.clear(); | 907 | dirDict.clear(); | ||
908 | 908 | | |||
909 | if (arcFile) { | 909 | if (arcFile) { | ||
910 | delete arcFile; | 910 | delete arcFile; | ||
911 | password.clear(); | 911 | password.clear(); | ||
912 | arcFile = 0L; | 912 | arcFile = nullptr; | ||
913 | } | 913 | } | ||
914 | QString newPath = path; | 914 | QString newPath = path; | ||
915 | if (newPath.right(1) != DIR_SEPARATOR) newPath = newPath + DIR_SEPARATOR; | 915 | if (newPath.right(1) != DIR_SEPARATOR) newPath = newPath + DIR_SEPARATOR; | ||
916 | for (int pos = 0; pos >= 0; pos = newPath.indexOf(DIR_SEPARATOR, pos + 1)) { | 916 | for (int pos = 0; pos >= 0; pos = newPath.indexOf(DIR_SEPARATOR, pos + 1)) { | ||
917 | QFileInfo qfi(newPath.left(pos)); | 917 | QFileInfo qfi(newPath.left(pos)); | ||
918 | if (qfi.exists() && !qfi.isDir()) { | 918 | if (qfi.exists() && !qfi.isDir()) { | ||
919 | QT_STATBUF stat_p; | 919 | QT_STATBUF stat_p; | ||
920 | QT_LSTAT(newPath.left(pos).toLocal8Bit(), &stat_p); | 920 | QT_LSTAT(newPath.left(pos).toLocal8Bit(), &stat_p); | ||
921 | arcFile = new KFileItem(QUrl::fromLocalFile(newPath.left(pos)), QString(), stat_p.st_mode); | 921 | arcFile = new KFileItem(QUrl::fromLocalFile(newPath.left(pos)), QString(), stat_p.st_mode); | ||
922 | break; | 922 | break; | ||
923 | } | 923 | } | ||
924 | } | 924 | } | ||
925 | if (!arcFile) { | 925 | if (!arcFile) { | ||
926 | // KRDEBUG("ERROR: " << path << " does not exist."); | 926 | // KRDEBUG("ERROR: " << path << " does not exist."); | ||
927 | error(ERR_DOES_NOT_EXIST, path); | 927 | error(ERR_DOES_NOT_EXIST, path); | ||
928 | return false; // file not found | 928 | return false; // file not found | ||
929 | } | 929 | } | ||
930 | currentCharset = metaData("Charset"); | 930 | currentCharset = metaData("Charset"); | ||
931 | 931 | | |||
932 | codec = QTextCodec::codecForName(currentCharset.toLatin1()); | 932 | codec = QTextCodec::codecForName(currentCharset.toLatin1()); | ||
933 | if (codec == 0) | 933 | if (codec == nullptr) | ||
934 | codec = QTextCodec::codecForMib(4 /* latin-1 */); | 934 | codec = QTextCodec::codecForMib(4 /* latin-1 */); | ||
935 | } | 935 | } | ||
936 | 936 | | |||
937 | /* FIX: file change can only be detected if the timestamp between the two consequent | 937 | /* FIX: file change can only be detected if the timestamp between the two consequent | ||
938 | changes is more than 1s. If the archive is continuously changing (check: move files | 938 | changes is more than 1s. If the archive is continuously changing (check: move files | ||
939 | inside the archive), krarc may errorneusly think, that the archive file is unchanged, | 939 | inside the archive), krarc may errorneusly think, that the archive file is unchanged, | ||
940 | because the timestamp is the same as the previous one. This situation can only occur | 940 | because the timestamp is the same as the previous one. This situation can only occur | ||
941 | if the modification time equals with the current time. While this condition is true, | 941 | if the modification time equals with the current time. While this condition is true, | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 971 | { | |||
1014 | // clear the dir dictionary | 1014 | // clear the dir dictionary | ||
1015 | 1015 | | |||
1016 | QHashIterator< QString, KIO::UDSEntryList *> lit(dirDict); | 1016 | QHashIterator< QString, KIO::UDSEntryList *> lit(dirDict); | ||
1017 | while (lit.hasNext()) | 1017 | while (lit.hasNext()) | ||
1018 | delete lit.next().value(); | 1018 | delete lit.next().value(); | ||
1019 | dirDict.clear(); | 1019 | dirDict.clear(); | ||
1020 | 1020 | | |||
1021 | // add the "/" directory | 1021 | // add the "/" directory | ||
1022 | UDSEntryList* root = new UDSEntryList(); | 1022 | auto* root = new UDSEntryList(); | ||
1023 | dirDict.insert(DIR_SEPARATOR, root); | 1023 | dirDict.insert(DIR_SEPARATOR, root); | ||
1024 | // and the "/" UDSEntry | 1024 | // and the "/" UDSEntry | ||
1025 | UDSEntry entry; | 1025 | UDSEntry entry; | ||
1026 | entry.insert(KIO::UDSEntry::UDS_NAME, "."); | 1026 | entry.insert(KIO::UDSEntry::UDS_NAME, "."); | ||
1027 | mode_t mode = parsePermString("drwxr-xr-x"); | 1027 | mode_t mode = parsePermString("drwxr-xr-x"); | ||
1028 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, mode & S_IFMT); // keep file type only | 1028 | entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, mode & S_IFMT); // keep file type only | ||
1029 | entry.insert(KIO::UDSEntry::UDS_ACCESS, mode & 07777); // keep permissions only | 1029 | entry.insert(KIO::UDSEntry::UDS_ACCESS, mode & 07777); // keep permissions only | ||
1030 | 1030 | | |||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 1099 | { | |||
1112 | 1112 | | |||
1113 | return arcDir; | 1113 | return arcDir; | ||
1114 | } | 1114 | } | ||
1115 | 1115 | | |||
1116 | UDSEntry* kio_krarcProtocol::findFileEntry(const QUrl &url) | 1116 | UDSEntry* kio_krarcProtocol::findFileEntry(const QUrl &url) | ||
1117 | { | 1117 | { | ||
1118 | KRFUNC; | 1118 | KRFUNC; | ||
1119 | QString arcDir = findArcDirectory(url); | 1119 | QString arcDir = findArcDirectory(url); | ||
1120 | if (arcDir.isEmpty()) return 0; | 1120 | if (arcDir.isEmpty()) return nullptr; | ||
1121 | 1121 | | |||
1122 | QHash<QString, KIO::UDSEntryList *>::iterator itef = dirDict.find(arcDir); | 1122 | QHash<QString, KIO::UDSEntryList *>::iterator itef = dirDict.find(arcDir); | ||
1123 | if (itef == dirDict.end()) | 1123 | if (itef == dirDict.end()) | ||
1124 | return 0; | 1124 | return nullptr; | ||
1125 | UDSEntryList* dirList = itef.value(); | 1125 | UDSEntryList* dirList = itef.value(); | ||
1126 | 1126 | | |||
1127 | QString name = getPath(url); | 1127 | QString name = getPath(url); | ||
1128 | if (getPath(arcFile->url(), QUrl::StripTrailingSlash) == getPath(url, QUrl::StripTrailingSlash)) name = '.'; // the '/' case | 1128 | if (getPath(arcFile->url(), QUrl::StripTrailingSlash) == getPath(url, QUrl::StripTrailingSlash)) name = '.'; // the '/' case | ||
1129 | else { | 1129 | else { | ||
1130 | if (name.right(1) == DIR_SEPARATOR) name.truncate(name.length() - 1); | 1130 | if (name.right(1) == DIR_SEPARATOR) name.truncate(name.length() - 1); | ||
1131 | name = name.mid(name.lastIndexOf(DIR_SEPARATOR) + 1); | 1131 | name = name.mid(name.lastIndexOf(DIR_SEPARATOR) + 1); | ||
1132 | } | 1132 | } | ||
1133 | 1133 | | |||
1134 | UDSEntryList::iterator entry; | 1134 | UDSEntryList::iterator entry; | ||
1135 | 1135 | | |||
1136 | for (entry = dirList->begin(); entry != dirList->end(); ++entry) { | 1136 | for (entry = dirList->begin(); entry != dirList->end(); ++entry) { | ||
1137 | if ((entry->contains(KIO::UDSEntry::UDS_NAME)) && | 1137 | if ((entry->contains(KIO::UDSEntry::UDS_NAME)) && | ||
1138 | (entry->stringValue(KIO::UDSEntry::UDS_NAME) == name)) | 1138 | (entry->stringValue(KIO::UDSEntry::UDS_NAME) == name)) | ||
1139 | return &(*entry); | 1139 | return &(*entry); | ||
1140 | } | 1140 | } | ||
1141 | return 0; | 1141 | return nullptr; | ||
1142 | } | 1142 | } | ||
1143 | 1143 | | |||
1144 | QString kio_krarcProtocol::nextWord(QString &s, char d) | 1144 | QString kio_krarcProtocol::nextWord(QString &s, char d) | ||
1145 | { | 1145 | { | ||
1146 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | 1146 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | ||
1147 | s = s.trimmed(); | 1147 | s = s.trimmed(); | ||
1148 | int j = s.indexOf(d, 0); | 1148 | int j = s.indexOf(d, 0); | ||
1149 | QString temp = s.left(j); // find the leftmost word. | 1149 | QString temp = s.left(j); // find the leftmost word. | ||
Show All 23 Lines | 1168 | #ifndef Q_WS_WIN | |||
1173 | // other permissions | 1173 | // other permissions | ||
1174 | if (perm[7] != '-') mode |= S_IROTH; | 1174 | if (perm[7] != '-') mode |= S_IROTH; | ||
1175 | if (perm[8] != '-') mode |= S_IWOTH; | 1175 | if (perm[8] != '-') mode |= S_IWOTH; | ||
1176 | if (perm[9] != '-') mode |= S_IXOTH; | 1176 | if (perm[9] != '-') mode |= S_IXOTH; | ||
1177 | #endif | 1177 | #endif | ||
1178 | return mode; | 1178 | return mode; | ||
1179 | } | 1179 | } | ||
1180 | 1180 | | |||
1181 | UDSEntryList* kio_krarcProtocol::addNewDir(QString path) | 1181 | UDSEntryList* kio_krarcProtocol::addNewDir(const QString& path) | ||
1182 | { | 1182 | { | ||
1183 | KRFUNC; | 1183 | KRFUNC; | ||
1184 | UDSEntryList* dir; | 1184 | UDSEntryList* dir; | ||
1185 | 1185 | | |||
1186 | // check if the current dir exists | 1186 | // check if the current dir exists | ||
1187 | QHash<QString, KIO::UDSEntryList *>::iterator itef = dirDict.find(path); | 1187 | QHash<QString, KIO::UDSEntryList *>::iterator itef = dirDict.find(path); | ||
1188 | if (itef != dirDict.end()) | 1188 | if (itef != dirDict.end()) | ||
1189 | return itef.value(); | 1189 | return itef.value(); | ||
Show All 37 Lines | 1224 | { | |||
1227 | UDSEntry entry; | 1227 | UDSEntry entry; | ||
1228 | 1228 | | |||
1229 | QString owner; | 1229 | QString owner; | ||
1230 | QString group; | 1230 | QString group; | ||
1231 | QString symlinkDest; | 1231 | QString symlinkDest; | ||
1232 | QString perm; | 1232 | QString perm; | ||
1233 | mode_t mode = 0666; | 1233 | mode_t mode = 0666; | ||
1234 | size_t size = 0; | 1234 | size_t size = 0; | ||
1235 | time_t time = ::time(0); | 1235 | time_t time = ::time(nullptr); | ||
1236 | QString fullName; | 1236 | QString fullName; | ||
1237 | 1237 | | |||
1238 | if (arcType == "zip") { | 1238 | if (arcType == "zip") { | ||
1239 | // permissions | 1239 | // permissions | ||
1240 | perm = nextWord(line); | 1240 | perm = nextWord(line); | ||
1241 | // ignore the next 2 fields | 1241 | // ignore the next 2 fields | ||
1242 | nextWord(line); nextWord(line); | 1242 | nextWord(line); nextWord(line); | ||
1243 | // size | 1243 | // size | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 1316 | if (arcType == "rpm") { | |||
1318 | fullName = nextWord(line); | 1318 | fullName = nextWord(line); | ||
1319 | // size | 1319 | // size | ||
1320 | size = nextWord(line).toULong(); | 1320 | size = nextWord(line).toULong(); | ||
1321 | // date & time | 1321 | // date & time | ||
1322 | time = nextWord(line).toULong(); | 1322 | time = nextWord(line).toULong(); | ||
1323 | // next field is md5sum, ignore it | 1323 | // next field is md5sum, ignore it | ||
1324 | nextWord(line); | 1324 | nextWord(line); | ||
1325 | // permissions | 1325 | // permissions | ||
1326 | mode = nextWord(line).toULong(0, 8); | 1326 | mode = nextWord(line).toULong(nullptr, 8); | ||
1327 | // Owner & Group | 1327 | // Owner & Group | ||
1328 | owner = nextWord(line); | 1328 | owner = nextWord(line); | ||
1329 | group = nextWord(line); | 1329 | group = nextWord(line); | ||
1330 | // symlink destination | 1330 | // symlink destination | ||
1331 | #ifndef Q_WS_WIN | 1331 | #ifndef Q_WS_WIN | ||
1332 | if (S_ISLNK(mode)) { | 1332 | if (S_ISLNK(mode)) { | ||
1333 | // ignore the next 3 fields | 1333 | // ignore the next 3 fields | ||
1334 | nextWord(line); nextWord(line); nextWord(line); | 1334 | nextWord(line); nextWord(line); nextWord(line); | ||
▲ Show 20 Lines • Show All 511 Lines • ▼ Show 20 Line(s) | |||||
1846 | QString kio_krarcProtocol::detectFullPathName(QString name) | 1846 | QString kio_krarcProtocol::detectFullPathName(QString name) | ||
1847 | { | 1847 | { | ||
1848 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | 1848 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | ||
1849 | KRDEBUG(name); | 1849 | KRDEBUG(name); | ||
1850 | 1850 | | |||
1851 | name = name + EXEC_SUFFIX; | 1851 | name = name + EXEC_SUFFIX; | ||
1852 | QStringList path = QString::fromLocal8Bit(qgetenv("PATH")).split(':'); | 1852 | QStringList path = QString::fromLocal8Bit(qgetenv("PATH")).split(':'); | ||
1853 | 1853 | | |||
1854 | for (QStringList::Iterator it = path.begin(); it != path.end(); ++it) { | 1854 | for (auto & it : path) { | ||
1855 | if (QDir(*it).exists(name)) { | 1855 | if (QDir(it).exists(name)) { | ||
1856 | QString dir = *it; | 1856 | QString dir = it; | ||
1857 | if (!dir.endsWith(DIR_SEPARATOR)) | 1857 | if (!dir.endsWith(DIR_SEPARATOR)) | ||
1858 | dir += DIR_SEPARATOR; | 1858 | dir += DIR_SEPARATOR; | ||
1859 | 1859 | | |||
1860 | return dir + name; | 1860 | return dir + name; | ||
1861 | } | 1861 | } | ||
1862 | } | 1862 | } | ||
1863 | return name; | 1863 | return name; | ||
1864 | } | 1864 | } | ||
1865 | 1865 | | |||
1866 | QString kio_krarcProtocol::fullPathName(QString name) | 1866 | QString kio_krarcProtocol::fullPathName(const QString& name) | ||
1867 | { | 1867 | { | ||
1868 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | 1868 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | ||
1869 | KRDEBUG(name); | 1869 | KRDEBUG(name); | ||
1870 | 1870 | | |||
1871 | QString supposedName = confGrp.readEntry(name, QString()); | 1871 | QString supposedName = confGrp.readEntry(name, QString()); | ||
1872 | if (supposedName.isEmpty()) | 1872 | if (supposedName.isEmpty()) | ||
1873 | supposedName = detectFullPathName(name); | 1873 | supposedName = detectFullPathName(name); | ||
1874 | return supposedName; | 1874 | return supposedName; | ||
Show All 15 Lines | 1878 | { | |||
1890 | const char *data = array.data(); | 1890 | const char *data = array.data(); | ||
1891 | for (int i = 0; i != size; i++) { | 1891 | for (int i = 0; i != size; i++) { | ||
1892 | unsigned short ch = (((int)data[ i ]) & 0xFF) + 0xE000; // user defined character | 1892 | unsigned short ch = (((int)data[ i ]) & 0xFF) + 0xE000; // user defined character | ||
1893 | result.append(QChar(ch)); | 1893 | result.append(QChar(ch)); | ||
1894 | } | 1894 | } | ||
1895 | return result; | 1895 | return result; | ||
1896 | } | 1896 | } | ||
1897 | 1897 | | |||
1898 | QByteArray kio_krarcProtocol::encodeString(QString str) | 1898 | QByteArray kio_krarcProtocol::encodeString(const QString& str) | ||
1899 | { | 1899 | { | ||
1900 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | 1900 | // Note: KRFUNC was not used here in order to avoid filling the log with too much information | ||
1901 | if (noencoding) | 1901 | if (noencoding) | ||
1902 | return QTextCodec::codecForLocale()->fromUnicode(str); | 1902 | return QTextCodec::codecForLocale()->fromUnicode(str); | ||
1903 | return codec->fromUnicode(str); | 1903 | return codec->fromUnicode(str); | ||
1904 | } | 1904 | } | ||
1905 | 1905 | | |||
1906 | QString kio_krarcProtocol::decodeString(char * buf) | 1906 | QString kio_krarcProtocol::decodeString(char * buf) | ||
Show All 28 Lines |
Q_DECL_OVERRIDE here and other places or we are moving to direct override across the board as we are in C++11 world already?