Ticket #4913: kde_bug325801.diff

File kde_bug325801.diff, 6.1 KB (added by Miklos Karacsony, 10 years ago)

Patch - 3

  • 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)  
    918918    }
    919919
    920920    extArcReady = false;
    921 
     921    isUnrarVersion5 = false;
    922922    if (!setArcFile(url))
    923923        return false;   /* if the archive was changed refresh the file information */
    924924
    bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced)  
    979979    if (arcType == "rar" || arcType == "arj" || arcType == "lha" || arcType == "7z") {
    980980        while (temp.readLine(buf, 1000) != -1) {
    981981            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            }
    982990            if (line.startsWith(QLatin1String("----------"))) break;
    983991        }
    984992    }
    bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced)  
    988996            // the rar list is ended with a ------ line.
    989997            if (line.startsWith(QLatin1String("----------"))) {
    990998                invalidLine = !invalidLine;
     999                if (isUnrarVersion5){
     1000                break;
     1001                }
     1002                else{
    9911003                continue;
     1004                }
    9921005            }
    9931006            if (invalidLine)
    9941007                continue;
    9951008            else {
     1009                if (!isUnrarVersion5){
    9961010                temp.readLine(buf, 1000);
    9971011                line = line + decodeString(buf);
     1012                }
    9981013                if (line[0] == '*') // encrypted archives starts with '*'
    9991014                    line[0] = ' ';
    10001015            }
    void kio_krarcProtocol::parseLine(int lineNo, QString line)  
    11901205        mode = parsePermString(perm);
    11911206    }
    11921207    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
    12071210        // permissions
    12081211        perm = nextWord(line);
    1209 
    12101212        if (perm.length() == 7) { // windows rar permission format
    12111213            bool isDir  = (perm.at(1).toLower() == 'd');
    12121214            bool isReadOnly = (perm.at(2).toLower() == 'r');
    void kio_krarcProtocol::parseLine(int lineNo, QString line)  
    12191221
    12201222        if (perm.length() != 10) perm = (perm.at(0) == 'd') ? "drwxr-xr-x" : "-rw-r--r--" ;
    12211223        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        }
    12221272    }
    12231273    if (arcType == "arj") {
    12241274        nextWord(line);
    bool kio_krarcProtocol::initArcParameters()  
    14961546        }
    14971547    } else if (arcType == "rar") {
    14981548        if (KStandardDirs::findExe("rar").isEmpty()) {
     1549            //unrar output now ANSI
     1550            noencoding = true;
    14991551            cmd     = fullPathName("unrar");
    15001552            listCmd << fullPathName("unrar") << "-c-" << "-v" << "v";
    15011553            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:  
    9696    bool archiveChanging;             //< true if the archive is currently changing.
    9797    bool newArchiveURL;               //< true if new archive was entered for the protocol
    9898    bool noencoding;                   //< 7z files use UTF-16, so encoding is unnecessary
     99    bool isUnrarVersion5;             //< thue if unrar have 5th version
    99100    KIO::filesize_t decompressedLen;  //< the number of the decompressed bytes
    100101    KFileItem* arcFile;               //< the archive file item.
    101102    QString arcPath;                  //< the archive location