|
Lines 55-61
Link Here
|
| 55 |
#include "arkutils.h" |
55 |
#include "arkutils.h" |
| 56 |
#include "filelistview.h" |
56 |
#include "filelistview.h" |
| 57 |
|
57 |
|
| 58 |
#define VERSION_5 5 |
58 |
// MMmmppbb ; M-major, m-minor, p-patch b-(100-beta) |
|
|
59 |
#define VERSION_MAJOR 1000000 |
| 60 |
#define VERSION_MINOR 10000 |
| 61 |
#define VERSION_PATCH 100 |
| 62 |
#define VERSION_5 (5*VERSION_MAJOR - VERSION_PATCH + 1 ) // consider betas |
| 59 |
|
63 |
|
| 60 |
RarArch::RarArch( ArkWidget *_gui, const TQString & _fileName ) |
64 |
RarArch::RarArch( ArkWidget *_gui, const TQString & _fileName ) |
| 61 |
: Arch( _gui, _fileName ), m_isFirstLine(false), m_version(0) |
65 |
: Arch( _gui, _fileName ), m_isFirstLine(false), m_version(0) |
|
Lines 95-105
bool RarArch::processLine( const TQCString &line )
Link Here
|
| 95 |
// Look for rar/unrar version first |
99 |
// Look for rar/unrar version first |
| 96 |
if (!m_version) |
100 |
if (!m_version) |
| 97 |
{ |
101 |
{ |
| 98 |
TQRegExp versionRegExp (TQString::fromLatin1 ("RAR\\s(\\d+)\\.(\\S+)\\s.*")); |
102 |
TQRegExp versionRegExp (TQString::fromLatin1 ("RAR\\s(\\d+)\\.(\\d+)\\s(beta (\\d+))?\\s+Copyright.*")); |
| 99 |
|
103 |
|
| 100 |
if (versionRegExp.exactMatch (uline)) |
104 |
if (versionRegExp.exactMatch (uline)) |
| 101 |
{ |
105 |
{ |
| 102 |
m_version = versionRegExp.capturedTexts()[1].toShort (); |
106 |
// Rar displays verion in form of "M.mp (beta b)?" |
|
|
107 |
m_version = versionRegExp.cap(1).toShort() * VERSION_MAJOR; |
| 108 |
m_version += versionRegExp.cap(2).toShort()/10 * VERSION_MINOR; |
| 109 |
m_version += versionRegExp.cap(2).toShort()%10 * VERSION_PATCH; |
| 110 |
|
| 111 |
if (!versionRegExp.cap(4).isEmpty()) { // beta versions should go befor release ones |
| 112 |
m_version -= VERSION_PATCH; |
| 113 |
m_version += versionRegExp.cap(4).toShort(); |
| 114 |
} |
| 103 |
|
115 |
|
| 104 |
if (m_version < VERSION_5) { |
116 |
if (m_version < VERSION_5) { |
| 105 |
m_headerString = "-------------------------------------------------------------------------------"; |
117 |
m_headerString = "-------------------------------------------------------------------------------"; |
|
Lines 150-155
bool RarArch::processLine( const TQCString &line )
Link Here
|
| 150 |
if (parsedData.size() >= 8 && nameRegExp.exactMatch (uline)) { |
162 |
if (parsedData.size() >= 8 && nameRegExp.exactMatch (uline)) { |
| 151 |
m_entryFilename = nameRegExp.capturedTexts()[2]; |
163 |
m_entryFilename = nameRegExp.capturedTexts()[2]; |
| 152 |
|
164 |
|
|
|
165 |
if(m_version < 5*VERSION_MAJOR+3*VERSION_MINOR) { // workaround bug with extra spaces in rar<5.3.0 |
| 166 |
m_entryFilename = m_entryFilename.stripWhiteSpace(); |
| 167 |
} |
| 168 |
|
| 153 |
entry << m_entryFilename; // filename |
169 |
entry << m_entryFilename; // filename |
| 154 |
entry << parsedData[ 1 ]; // size |
170 |
entry << parsedData[ 1 ]; // size |
| 155 |
entry << parsedData[ 2 ]; // packed |
171 |
entry << parsedData[ 2 ]; // packed |
|
Lines 163-175
bool RarArch::processLine( const TQCString &line )
Link Here
|
| 163 |
return false; |
179 |
return false; |
| 164 |
} |
180 |
} |
| 165 |
} |
181 |
} |
| 166 |
|
182 |
|
| 167 |
// send to GUI |
183 |
// send to GUI |
| 168 |
// Use addOrUpdateItem() rather than addItem() due to recent RAR version |
184 |
// Use addOrUpdateItem() rather than addItem() due to recent RAR version |
| 169 |
// place directories in archive after their content. |
185 |
// place directories in archive after their content. |
| 170 |
FileLVI *item = m_gui->fileList()->addOrUpdateItem( entry ); |
186 |
FileLVI *item = m_gui->fileList()->addOrUpdateItem( entry ); |
| 171 |
|
187 |
|
| 172 |
// But archives packaged with older versions of ark may have directories |
188 |
// But archives packaged with older versions of rar may have directories |
| 173 |
// entries first, so make sure they will get an appropriate icon |
189 |
// entries first, so make sure they will get an appropriate icon |
| 174 |
if (item && entry[5].find('d', 0, false) != -1) { |
190 |
if (item && entry[5].find('d', 0, false) != -1) { |
| 175 |
// check attr's for d (case insensitive to handle windows archives) |
191 |
// check attr's for d (case insensitive to handle windows archives) |