[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/karchiver
From: Eric Coquelle <eric.coquelle () gmail ! com>
Date: 2006-09-15 0:33:39
Message-ID: 1158280419.795005.4861.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 584481 by coquelle:
Fixed choice of extraction directory
M +52 -30 crar.cpp
--- trunk/kdenonbeta/karchiver/crar.cpp #584480:584481
@@ -27,7 +27,7 @@
connect(&processread,SIGNAL(receivedStderr(KProcess*, char*, \
int)),this,SLOT(haveStdErr(KProcess*,char*,int))); \
connect(&processread,SIGNAL(receivedStdout(KProcess*, char*, \
int)),this,SLOT(haveSdtOut(KProcess*,char*,int)));
- connect(&processread,SIGNAL(processExited \
(KProcess*)),this,SLOT(endProcess(KProcess*))); + \
connect(&processread,SIGNAL(processExited \
(KProcess*)),this,SLOT(endReadProcess(KProcess*))); \
connect(&processextract,SIGNAL(receivedStdout(KProcess*, char*, \
int)),this,SLOT(haveSdtOutExtract(KProcess*,char*,int))); \
connect(&processextract,SIGNAL(processExited \
(KProcess*)),this,SLOT(endProcess(KProcess*))); connect(&processextract, \
SIGNAL(receivedStderr(KProcess *, char *, int)),this, \
SLOT(haveSdtErrExtract(KProcess*,char*,int))); @@ -53,6 +53,12 @@
if(mustreadoncemore&&passwordrequired)
mustreadoncemore=false;
+ if(viewbydirectories)
+ {
+ rarfile=new MyKRar(archiveName);
+ if( !rarfile->open(IO_ReadOnly) )
+ errors.append("KZip Process failed to open file");
+ }
processread <<"rar";
processread << "v";
if(!passwordrequired)
@@ -186,63 +192,68 @@
/** we recive some informations through the standard
output of the process */
void CRar::haveSdtOut(KProcess *, char *buffer, int length){
- //Has user canceled current action ?
- if(stopreadprocess)
- return;
+ //Has user canceled current action ?
+ if(stopreadprocess)
+ return;
- // This section has been taken from ark:
- //1997-1999: Rob Palmbos palm9744@kettering.edu
- //2000: Corel Corporation (author: Emily Ezust, emilye@corel.com)
- //and adapted to karchiver
-
-
+ // This section has been taken from ark:
+ //1997-1999: Rob Palmbos palm9744@kettering.edu
+ //2000: Corel Corporation (author: Emily Ezust, emilye@corel.com)
+ //and adapted to karchiver
+
+
char c = buffer[length];
buffer[length] = '\0';
-
+
int lfChar, startChar = 0;
-
+
while(!finished)
{
for(lfChar = startChar; buffer[lfChar] != '\n' && lfChar < length;
- lfChar++);
-
+ lfChar++);
+
if(buffer[lfChar] != '\n') break; // We are done all the complete lines
-
+
buffer[lfChar] = '\0';
m_buffer.append(buffer + startChar);
buffer[lfChar] = '\n';
startChar = lfChar + 1;
-
+
if(processingRarHeader==HEADER_PROCESSED)
{
- if(m_buffer.find("--------") == -1 )
+ if(m_buffer.find("--------") == -1 )
+ {
+ if(viewbydirectories)
+ rarfile->displayRarArchiveContent(m_buffer);
+ else
displayRarArchiveContent(m_buffer);
- else
+ }
+ else
finished=true;
}
else if(processingRarHeader==BEGIN_HEADER)
{
- if(m_buffer.find("for help") != -1)
+ if(m_buffer.find("for help") != -1)
processingRarHeader=BEGIN_COMMENT;
}
else if(processingRarHeader==BEGIN_COMMENT)
{
- if(m_buffer.find("Pathname/Comment") != -1)
+ if(m_buffer.find("Pathname/Comment") != -1)
processingRarHeader=END_COMMENT;
- else
+ else
archivecomments.append(m_buffer);
}
else if(processingRarHeader==END_COMMENT)
{
- if( m_buffer.find("--------") != -1 )
+ if( m_buffer.find("--------") != -1 )
processingRarHeader=HEADER_PROCESSED;
}
m_buffer = "";
}
if(!finished)
- m_buffer.append(buffer + startChar); // Append what's left of the buffer
-
+ m_buffer.append(buffer + startChar); // Append what's left of the buffer
+
buffer[length] = c;
}
@@ -280,6 +291,15 @@
emit(archiveReadEnded());
}
+void CRar::endReadProcess(KProcess*){
+ if(!mustreadoncemore)
+ {
+ if(viewbydirectories)
+ CArchive::displayArchiveContent(rarfile->directory(),QString::null);
+ emit(archiveReadEnded());
+ }
+}
+
/** Upon the kind of archive, choose the right
*uncompressor and extract all or some files
*@extractall = 9: extract to karchiveur's temp directory (for viewing)
@@ -315,7 +335,7 @@
processextract << "-o+";
processextract << archiveName;
- processextract << "-d"+extractpath;
+ processextract << "-d" << extractpath;
if((extractall!=EXTRACTONE)&&(extractall!=EXTRACTONE_AND_BLOCK)&&(!checkFiles(extractpath, \
extractall))) {
@@ -352,15 +372,15 @@
/** delete @param filestodelete from current archive */
void CRar::removeFilesFromArchive (QStringList filestodelete){
kdDebug()<<("In:removeFilesFromArchive_RAR\n");
- processread.clearArguments();
- processread << "rar" << "d";
- processread << archiveName;
+ processadd.clearArguments();
+ processadd << "rar" << "d";
+ processadd << archiveName;
for (QStringList::Iterator f = filestodelete.begin(); f!=filestodelete.end(); ++f \
) {
kdDebug()<<QString("Will remove:%1*").arg(*f)<<endl;
- processread << *f;
+ processadd << *f;
}
- processread.start(KProcess::Block);
+ processadd.start(KProcess::Block);
kdDebug()<<("Ok:removeFilesFromArchive_RAR\n");
}
@@ -443,6 +463,8 @@
setPassword(pass);
passwordrequired=true;
processread.kill();
+ if(viewbydirectories)
+ delete rarfile;
displayArchiveContent();
}
else
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic