Ticket #4913: kde_bug325801.diff
File kde_bug325801.diff, 6.1 KB (added by , 10 years ago) |
---|
-
krArc/krarc.cpp
commit aca6a97fc31a80b5a35ec1afbee8f45a728b8a19 Author: Alexander Balakhnin <Croman13n3c@gmail.com> Date: Sun Oct 27 19:48:38 2013 +0300 Fixing krarc support for new unrar 5 diff --git a/krArc/krarc.cpp b/krArc/krarc.cpp index fc52ad5..c60a1f5 100644
a b bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced) 918 918 } 919 919 920 920 extArcReady = false; 921 921 isUnrarVersion5 = false; 922 922 if (!setArcFile(url)) 923 923 return false; /* if the archive was changed refresh the file information */ 924 924 … … bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced) 979 979 if (arcType == "rar" || arcType == "arj" || arcType == "lha" || arcType == "7z") { 980 980 while (temp.readLine(buf, 1000) != -1) { 981 981 line = decodeString(buf); 982 //detect unrar version 983 if (line.startsWith(QLatin1String("UNRAR"))) { 984 //skip line with "UNRAR" 985 nextWord(line); 986 if (nextWord(line).left(1).toInt()==5){ 987 isUnrarVersion5 = true; 988 } 989 } 982 990 if (line.startsWith(QLatin1String("----------"))) break; 983 991 } 984 992 } … … bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced) 988 996 // the rar list is ended with a ------ line. 989 997 if (line.startsWith(QLatin1String("----------"))) { 990 998 invalidLine = !invalidLine; 999 if (isUnrarVersion5){ 1000 break; 1001 } 1002 else{ 991 1003 continue; 1004 } 992 1005 } 993 1006 if (invalidLine) 994 1007 continue; 995 1008 else { 1009 if (!isUnrarVersion5){ 996 1010 temp.readLine(buf, 1000); 997 1011 line = line + decodeString(buf); 1012 } 998 1013 if (line[0] == '*') // encrypted archives starts with '*' 999 1014 line[0] = ' '; 1000 1015 } … … void kio_krarcProtocol::parseLine(int lineNo, QString line) 1190 1205 mode = parsePermString(perm); 1191 1206 } 1192 1207 if (arcType == "rar") { 1193 // full name 1194 fullName = nextWord(line, '\n'); 1195 // size 1196 size = nextWord(line).toLong(); 1197 // ignore the next 2 fields 1198 nextWord(line); nextWord(line); 1199 // date & time 1200 QString d = nextWord(line); 1201 int year = 1900 + d.mid(6, 2).toInt(); 1202 if (year < 1930) year += 100; 1203 QDate qdate(year, d.mid(3, 2).toInt(), d.mid(0, 2).toInt()); 1204 QString t = nextWord(line); 1205 QTime qtime(t.mid(0, 2).toInt(), t.mid(3, 2).toInt(), 0); 1206 time = QDateTime(qdate, qtime).toTime_t(); 1208 if (isUnrarVersion5){ 1209 1207 1210 // permissions 1208 1211 perm = nextWord(line); 1209 1210 1212 if (perm.length() == 7) { // windows rar permission format 1211 1213 bool isDir = (perm.at(1).toLower() == 'd'); 1212 1214 bool isReadOnly = (perm.at(2).toLower() == 'r'); … … void kio_krarcProtocol::parseLine(int lineNo, QString line) 1219 1221 1220 1222 if (perm.length() != 10) perm = (perm.at(0) == 'd') ? "drwxr-xr-x" : "-rw-r--r--" ; 1221 1223 mode = parsePermString(perm); 1224 // size 1225 size = nextWord(line).toLong(); 1226 // ignore the next 2 fields 1227 nextWord(line); nextWord(line); 1228 // date & time 1229 QString d = nextWord(line); 1230 int year = 1900 + d.mid(6, 2).toInt(); 1231 if (year < 1930) year += 100; 1232 QDate qdate(year, d.mid(3, 2).toInt(), d.mid(0, 2).toInt()); 1233 QString t = nextWord(line); 1234 QTime qtime(t.mid(0, 2).toInt(), t.mid(3, 2).toInt(), 0); 1235 time = QDateTime(qdate, qtime).toTime_t(); 1236 // ignore the next 1 fields 1237 nextWord(line); 1238 fullName = nextWord(line, '\n'); 1239 } 1240 else{ 1241 1242 // full name 1243 fullName = nextWord(line, '\n'); 1244 // size 1245 size = nextWord(line).toLong(); 1246 // ignore the next 2 fields 1247 nextWord(line); nextWord(line); 1248 // date & time 1249 QString d = nextWord(line); 1250 int year = 1900 + d.mid(6, 2).toInt(); 1251 if (year < 1930) year += 100; 1252 QDate qdate(year, d.mid(3, 2).toInt(), d.mid(0, 2).toInt()); 1253 QString t = nextWord(line); 1254 QTime qtime(t.mid(0, 2).toInt(), t.mid(3, 2).toInt(), 0); 1255 time = QDateTime(qdate, qtime).toTime_t(); 1256 // permissions 1257 perm = nextWord(line); 1258 1259 if (perm.length() == 7) { // windows rar permission format 1260 bool isDir = (perm.at(1).toLower() == 'd'); 1261 bool isReadOnly = (perm.at(2).toLower() == 'r'); 1262 1263 perm = isDir ? "drwxr-xr-x" : "-rw-r--r--"; 1264 1265 if (isReadOnly) 1266 perm[ 2 ] = '-'; 1267 } 1268 1269 if (perm.length() != 10) perm = (perm.at(0) == 'd') ? "drwxr-xr-x" : "-rw-r--r--" ; 1270 mode = parsePermString(perm); 1271 } 1222 1272 } 1223 1273 if (arcType == "arj") { 1224 1274 nextWord(line); … … bool kio_krarcProtocol::initArcParameters() 1496 1546 } 1497 1547 } else if (arcType == "rar") { 1498 1548 if (KStandardDirs::findExe("rar").isEmpty()) { 1549 //unrar output now ANSI 1550 noencoding = true; 1499 1551 cmd = fullPathName("unrar"); 1500 1552 listCmd << fullPathName("unrar") << "-c-" << "-v" << "v"; 1501 1553 getCmd << fullPathName("unrar") << "p" << "-ierr" << "-idp" << "-c-" << "-y"; -
krArc/krarc.h
diff --git a/krArc/krarc.h b/krArc/krarc.h index f6119d0..b6b7505 100644
a b private: 96 96 bool archiveChanging; //< true if the archive is currently changing. 97 97 bool newArchiveURL; //< true if new archive was entered for the protocol 98 98 bool noencoding; //< 7z files use UTF-16, so encoding is unnecessary 99 bool isUnrarVersion5; //< thue if unrar have 5th version 99 100 KIO::filesize_t decompressedLen; //< the number of the decompressed bytes 100 101 KFileItem* arcFile; //< the archive file item. 101 102 QString arcPath; //< the archive location