@ -55,7 +55,11 @@
# include "arkutils.h"
# include "arkutils.h"
# include "filelistview.h"
# include "filelistview.h"
# define VERSION_5 5
// MMmmppbb ; M-major, m-minor, p-patch b-(100-beta)
# define VERSION_MAJOR 1000000
# define VERSION_MINOR 10000
# define VERSION_PATCH 100
# define VERSION_5 (5*VERSION_MAJOR - VERSION_PATCH + 1 ) // consider betas
RarArch : : RarArch ( ArkWidget * _gui , const TQString & _fileName )
RarArch : : RarArch ( ArkWidget * _gui , const TQString & _fileName )
: Arch ( _gui , _fileName ) , m_isFirstLine ( false ) , m_version ( 0 )
: Arch ( _gui , _fileName ) , m_isFirstLine ( false ) , m_version ( 0 )
@ -95,11 +99,19 @@ bool RarArch::processLine( const TQCString &line )
// Look for rar/unrar version first
// Look for rar/unrar version first
if ( ! m_version )
if ( ! m_version )
{
{
TQRegExp versionRegExp ( TQString : : fromLatin1 ( " RAR \\ s( \\ d+) \ \ . ( \ \ S+ ) \ \ s . * " )) ;
TQRegExp versionRegExp ( TQString : : fromLatin1 ( " RAR \\ s( \\ d+) \ \ . ( \ \ d+ ) \ \ s ( beta ( \ \ d + ) ) ? \ \ s + Copyright . * " )) ;
if ( versionRegExp . exactMatch ( uline ) )
if ( versionRegExp . exactMatch ( uline ) )
{
{
m_version = versionRegExp . capturedTexts ( ) [ 1 ] . toShort ( ) ;
// Rar displays verion in form of "M.mp (beta b)?"
m_version = versionRegExp . cap ( 1 ) . toShort ( ) * VERSION_MAJOR ;
m_version + = versionRegExp . cap ( 2 ) . toShort ( ) / 10 * VERSION_MINOR ;
m_version + = versionRegExp . cap ( 2 ) . toShort ( ) % 10 * VERSION_PATCH ;
if ( ! versionRegExp . cap ( 4 ) . isEmpty ( ) ) { // beta versions should go befor release ones
m_version - = VERSION_PATCH ;
m_version + = versionRegExp . cap ( 4 ) . toShort ( ) ;
}
if ( m_version < VERSION_5 ) {
if ( m_version < VERSION_5 ) {
m_headerString = " ------------------------------------------------------------------------------- " ;
m_headerString = " ------------------------------------------------------------------------------- " ;
@ -150,6 +162,10 @@ bool RarArch::processLine( const TQCString &line )
if ( parsedData . size ( ) > = 8 & & nameRegExp . exactMatch ( uline ) ) {
if ( parsedData . size ( ) > = 8 & & nameRegExp . exactMatch ( uline ) ) {
m_entryFilename = nameRegExp . capturedTexts ( ) [ 2 ] ;
m_entryFilename = nameRegExp . capturedTexts ( ) [ 2 ] ;
if ( m_version < 5 * VERSION_MAJOR + 3 * VERSION_MINOR ) { // workaround bug with extra spaces in rar<5.3.0
m_entryFilename = m_entryFilename . stripWhiteSpace ( ) ;
}
entry < < m_entryFilename ; // filename
entry < < m_entryFilename ; // filename
entry < < parsedData [ 1 ] ; // size
entry < < parsedData [ 1 ] ; // size
entry < < parsedData [ 2 ] ; // packed
entry < < parsedData [ 2 ] ; // packed
@ -169,7 +185,7 @@ bool RarArch::processLine( const TQCString &line )
// place directories in archive after their content.
// place directories in archive after their content.
FileLVI * item = m_gui - > fileList ( ) - > addOrUpdateItem ( entry ) ;
FileLVI * item = m_gui - > fileList ( ) - > addOrUpdateItem ( entry ) ;
// But archives packaged with older versions of ark may have directories
// But archives packaged with older versions of r ar may have directories
// entries first, so make sure they will get an appropriate icon
// entries first, so make sure they will get an appropriate icon
if ( item & & entry [ 5 ] . find ( ' d ' , 0 , false ) ! = - 1 ) {
if ( item & & entry [ 5 ] . find ( ' d ' , 0 , false ) ! = - 1 ) {
// check attr's for d (case insensitive to handle windows archives)
// check attr's for d (case insensitive to handle windows archives)