kioslave: log floppy KIO slave messages to specialized area

7101 is reserved for kio_file

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-10-22 21:52:14 +03:00
parent cb142336e4
commit 72871a1ded
2 changed files with 67 additions and 67 deletions

View file

@ -54,7 +54,7 @@ int kdemain( int argc, char **argv )
fprintf(stderr, "Usage: kio_floppy protocol domain-socket1 domain-socket2\n"); fprintf(stderr, "Usage: kio_floppy protocol domain-socket1 domain-socket2\n");
exit(-1); exit(-1);
} }
kDebug(7101) << "Floppy: kdemain: starting"; kDebug(7104) << "Floppy: kdemain: starting";
FloppyProtocol slave(argv[2], argv[3]); FloppyProtocol slave(argv[2], argv[3]);
slave.dispatchLoop(); slave.dispatchLoop();
@ -83,7 +83,7 @@ FloppyProtocol::FloppyProtocol (const QByteArray &pool, const QByteArray &app )
,m_stdoutSize(0) ,m_stdoutSize(0)
,m_stderrSize(0) ,m_stderrSize(0)
{ {
kDebug(7101)<<"Floppy::Floppy: -"<<pool<<"-"; kDebug(7104)<<"Floppy::Floppy: -"<<pool<<"-";
} }
FloppyProtocol::~FloppyProtocol() FloppyProtocol::~FloppyProtocol()
@ -98,7 +98,7 @@ FloppyProtocol::~FloppyProtocol()
int FloppyProtocol::readStdout() int FloppyProtocol::readStdout()
{ {
//kDebug(7101)<<"Floppy::readStdout"; //kDebug(7104)<<"Floppy::readStdout";
if (m_mtool==0) return 0; if (m_mtool==0) return 0;
char buffer[16*1024]; char buffer[16*1024];
@ -107,7 +107,7 @@ int FloppyProtocol::readStdout()
//+1 gives us room for a terminating 0 //+1 gives us room for a terminating 0
char *newBuffer=new char[length+m_stdoutSize+1]; char *newBuffer=new char[length+m_stdoutSize+1];
kDebug(7101)<<"Floppy::readStdout(): length: "<<length<<" m_tsdoutSize: "<<m_stdoutSize<<" +1="<<length+m_stdoutSize+1; kDebug(7104)<<"Floppy::readStdout(): length: "<<length<<" m_tsdoutSize: "<<m_stdoutSize<<" +1="<<length+m_stdoutSize+1;
if (m_stdoutBuffer!=0) if (m_stdoutBuffer!=0)
{ {
memcpy(newBuffer, m_stdoutBuffer, m_stdoutSize); memcpy(newBuffer, m_stdoutBuffer, m_stdoutSize);
@ -118,15 +118,15 @@ int FloppyProtocol::readStdout()
delete [] m_stdoutBuffer; delete [] m_stdoutBuffer;
m_stdoutBuffer=newBuffer; m_stdoutBuffer=newBuffer;
//kDebug(7101)<<"Floppy::readStdout(): -"<<m_stdoutBuffer<<"-"; //kDebug(7104)<<"Floppy::readStdout(): -"<<m_stdoutBuffer<<"-";
//kDebug(7101)<<"Floppy::readStdout ends"; //kDebug(7104)<<"Floppy::readStdout ends";
return length; return length;
} }
int FloppyProtocol::readStderr() int FloppyProtocol::readStderr()
{ {
//kDebug(7101)<<"Floppy::readStderr"; //kDebug(7104)<<"Floppy::readStderr";
if (m_mtool==0) return 0; if (m_mtool==0) return 0;
/*struct timeval tv; /*struct timeval tv;
@ -136,7 +136,7 @@ int FloppyProtocol::readStderr()
char buffer[16*1024]; char buffer[16*1024];
int length=::read(m_mtool->stderrFD(),buffer,16*1024); int length=::read(m_mtool->stderrFD(),buffer,16*1024);
kDebug(7101)<<"Floppy::readStderr(): read "<<length<<" bytes"; kDebug(7104)<<"Floppy::readStderr(): read "<<length<<" bytes";
if (length<=0) return 0; if (length<=0) return 0;
//+1 gives us room for a terminating 0 //+1 gives us room for a terminating 0
@ -147,26 +147,26 @@ int FloppyProtocol::readStderr()
newBuffer[m_stderrSize]='\0'; newBuffer[m_stderrSize]='\0';
delete [] m_stderrBuffer; delete [] m_stderrBuffer;
m_stderrBuffer=newBuffer; m_stderrBuffer=newBuffer;
kDebug(7101)<<"Floppy::readStderr(): -"<<m_stderrBuffer<<"-"; kDebug(7104)<<"Floppy::readStderr(): -"<<m_stderrBuffer<<"-";
return length; return length;
} }
void FloppyProtocol::clearBuffers() void FloppyProtocol::clearBuffers()
{ {
kDebug(7101)<<"Floppy::clearBuffers()"; kDebug(7104)<<"Floppy::clearBuffers()";
m_stdoutSize=0; m_stdoutSize=0;
m_stderrSize=0; m_stderrSize=0;
delete [] m_stdoutBuffer; delete [] m_stdoutBuffer;
m_stdoutBuffer=0; m_stdoutBuffer=0;
delete [] m_stderrBuffer; delete [] m_stderrBuffer;
m_stderrBuffer=0; m_stderrBuffer=0;
//kDebug(7101)<<"Floppy::clearBuffers() ends"; //kDebug(7104)<<"Floppy::clearBuffers() ends";
} }
void FloppyProtocol::terminateBuffers() void FloppyProtocol::terminateBuffers()
{ {
//kDebug(7101)<<"Floppy::terminateBuffers()"; //kDebug(7104)<<"Floppy::terminateBuffers()";
//append a terminating 0 to be sure //append a terminating 0 to be sure
if (m_stdoutBuffer!=0) if (m_stdoutBuffer!=0)
{ {
@ -176,7 +176,7 @@ void FloppyProtocol::terminateBuffers()
{ {
m_stderrBuffer[m_stderrSize]='\0'; m_stderrBuffer[m_stderrSize]='\0';
} }
//kDebug(7101)<<"Floppy::terminateBuffers() ends"; //kDebug(7104)<<"Floppy::terminateBuffers() ends";
} }
bool FloppyProtocol::stopAfterError(const KUrl& url, const QString& drive) bool FloppyProtocol::stopAfterError(const KUrl& url, const QString& drive)
@ -188,7 +188,7 @@ bool FloppyProtocol::stopAfterError(const KUrl& url, const QString& drive)
QString outputString(m_stderrBuffer); QString outputString(m_stderrBuffer);
QTextStream output(&outputString, QIODevice::ReadOnly); QTextStream output(&outputString, QIODevice::ReadOnly);
QString line=output.readLine(); QString line=output.readLine();
kDebug(7101)<<"line: -"<<line<<"-"; kDebug(7104)<<"line: -"<<line<<"-";
if (line.indexOf("resource busy") > -1) if (line.indexOf("resource busy") > -1)
{ {
error( KIO::ERR_SLAVE_DEFINED, i18n("Could not access drive %1.\nThe drive is still busy.\nWait until it is inactive and then try again.", drive)); error( KIO::ERR_SLAVE_DEFINED, i18n("Could not access drive %1.\nThe drive is still busy.\nWait until it is inactive and then try again.", drive));
@ -247,7 +247,7 @@ bool FloppyProtocol::stopAfterError(const KUrl& url, const QString& drive)
void FloppyProtocol::listDir( const KUrl& _url) void FloppyProtocol::listDir( const KUrl& _url)
{ {
kDebug(7101)<<"Floppy::listDir() "<<_url.path(); kDebug(7104)<<"Floppy::listDir() "<<_url.path();
KUrl url(_url); KUrl url(_url);
QString path(url.path()); QString path(url.path());
@ -322,13 +322,13 @@ void FloppyProtocol::listDir( const KUrl& _url)
while (!output.atEnd()) while (!output.atEnd())
{ {
line=output.readLine(); line=output.readLine();
kDebug(7101)<<"Floppy::listDir(): line: -"<<line<<"- length: "<<line.length(); kDebug(7104)<<"Floppy::listDir(): line: -"<<line<<"- length: "<<line.length();
if (mode==0) if (mode==0)
{ {
if (line.isEmpty()) if (line.isEmpty())
{ {
kDebug(7101)<<"Floppy::listDir(): switching to mode 1"; kDebug(7104)<<"Floppy::listDir(): switching to mode 1";
mode=1; mode=1;
} }
} }
@ -336,7 +336,7 @@ void FloppyProtocol::listDir( const KUrl& _url)
{ {
if (line[0]==' ') if (line[0]==' ')
{ {
kDebug(7101)<<"Floppy::listDir(): ende"; kDebug(7104)<<"Floppy::listDir(): ende";
totalSize(totalNumber); totalSize(totalNumber);
break; break;
} }
@ -345,7 +345,7 @@ void FloppyProtocol::listDir( const KUrl& _url)
if (info.isValid) if (info.isValid)
{ {
createUDSEntry(info,entry); createUDSEntry(info,entry);
//kDebug(7101)<<"Floppy::listDir(): creating UDSEntry"; //kDebug(7104)<<"Floppy::listDir(): creating UDSEntry";
listEntry( entry, false); listEntry( entry, false);
totalNumber++; totalNumber++;
} }
@ -353,7 +353,7 @@ void FloppyProtocol::listDir( const KUrl& _url)
} }
listEntry( entry, true ); // ready listEntry( entry, true ); // ready
finished(); finished();
//kDebug(7101)<<"Floppy::listDir() ends"; //kDebug(7104)<<"Floppy::listDir() ends";
} }
void FloppyProtocol::errorMissingMToolsProgram(const QString& name) void FloppyProtocol::errorMissingMToolsProgram(const QString& name)
@ -372,7 +372,7 @@ void FloppyProtocol::createUDSEntry(const StatInfo& info, UDSEntry& entry)
StatInfo FloppyProtocol::createStatInfo(const QString line, bool makeStat, const QString& dirName) StatInfo FloppyProtocol::createStatInfo(const QString line, bool makeStat, const QString& dirName)
{ {
//kDebug(7101)<<"Floppy::createUDSEntry()"; //kDebug(7104)<<"Floppy::createUDSEntry()";
QString name; QString name;
QString size; QString size;
bool isDir(false); bool isDir(false);
@ -383,7 +383,7 @@ StatInfo FloppyProtocol::createStatInfo(const QString line, bool makeStat, const
if (line.mid(13,5)=="<DIR>") if (line.mid(13,5)=="<DIR>")
{ {
//kDebug(7101)<<"Floppy::createUDSEntry() isDir"; //kDebug(7104)<<"Floppy::createUDSEntry() isDir";
size="1024"; size="1024";
isDir=true; isDir=true;
} }
@ -391,13 +391,13 @@ StatInfo FloppyProtocol::createStatInfo(const QString line, bool makeStat, const
{ {
p = line.indexOf(' ',p-1); p = line.indexOf(' ',p-1);
size=line.mid(13,p-13); size=line.mid(13,p-13);
//kDebug(7101)<<"Floppy::createUDSEntry() size: -"<<size<<"-"; //kDebug(7104)<<"Floppy::createUDSEntry() size: -"<<size<<"-";
} }
if (line.length()==p+19) if (line.length()==p+19)
{ {
int nameLength=line.indexOf(' '); int nameLength=line.indexOf(' ');
kDebug(7101)<<"Floppy::createStatInfo: line find: "<<nameLength <<"= -"<<line<<"-"; kDebug(7104)<<"Floppy::createStatInfo: line find: "<<nameLength <<"= -"<<line<<"-";
if (nameLength>0) if (nameLength>0)
{ {
name=line.mid(0,nameLength); name=line.mid(0,nameLength);
@ -406,12 +406,12 @@ StatInfo FloppyProtocol::createStatInfo(const QString line, bool makeStat, const
if (!ext.isEmpty()) if (!ext.isEmpty())
name+='.'+ext; name+='.'+ext;
} }
kDebug(7101)<<"Floppy::createStatInfo() name 8.3= -"<<name<<"-"; kDebug(7104)<<"Floppy::createStatInfo() name 8.3= -"<<name<<"-";
} }
else if (line.length()>p+19) else if (line.length()>p+19)
{ {
name=line.mid(p+20); name=line.mid(p+20);
kDebug(7101)<<"Floppy::createStatInfo() name vfat: -"<<name<<"-"; kDebug(7104)<<"Floppy::createStatInfo() name vfat: -"<<name<<"-";
} }
if ((name==".") || (name=="..")) if ((name==".") || (name==".."))
{ {
@ -439,7 +439,7 @@ StatInfo FloppyProtocol::createStatInfo(const QString line, bool makeStat, const
} }
hour=line.mid(p+13,2); hour=line.mid(p+13,2);
minute=line.mid(p+16,2); minute=line.mid(p+16,2);
//kDebug(7101)<<"Floppy::createUDSEntry() day: -"<<day<<"-"<<month<<"-"<<year<<"- -"<<hour<<"-"<<minute<<"-"; //kDebug(7104)<<"Floppy::createUDSEntry() day: -"<<day<<"-"<<month<<"-"<<year<<"- -"<<hour<<"-"<<minute<<"-";
if (name.isEmpty()) if (name.isEmpty())
{ {
@ -461,7 +461,7 @@ StatInfo FloppyProtocol::createStatInfo(const QString line, bool makeStat, const
info.isDir=isDir; info.isDir=isDir;
info.isValid=true; info.isValid=true;
//kDebug(7101)<<"Floppy::createUDSEntry() ends"; //kDebug(7104)<<"Floppy::createUDSEntry() ends";
return info; return info;
} }
@ -476,7 +476,7 @@ StatInfo FloppyProtocol::_stat(const KUrl& url)
if (floppyPath.isEmpty()) if (floppyPath.isEmpty())
{ {
kDebug(7101)<<"Floppy::_stat(): floppyPath.isEmpty()"; kDebug(7104)<<"Floppy::_stat(): floppyPath.isEmpty()";
info.name=path; info.name=path;
info.size=1024; info.size=1024;
info.time=0; info.time=0;
@ -487,13 +487,13 @@ StatInfo FloppyProtocol::_stat(const KUrl& url)
return info; return info;
} }
//kDebug(7101)<<"Floppy::_stat(): delete m_mtool"; //kDebug(7104)<<"Floppy::_stat(): delete m_mtool";
delete m_mtool; delete m_mtool;
QStringList args; QStringList args;
args<<"mdir"<<"-a"<<(drive+floppyPath); args<<"mdir"<<"-a"<<(drive+floppyPath);
//kDebug(7101)<<"Floppy::_stat(): create m_mtool"; //kDebug(7104)<<"Floppy::_stat(): create m_mtool";
m_mtool=new Program(args); m_mtool=new Program(args);
if (!m_mtool->start()) if (!m_mtool->start())
@ -531,7 +531,7 @@ StatInfo FloppyProtocol::_stat(const KUrl& url)
} }
} while (!loopFinished); } while (!loopFinished);
//kDebug(7101)<<"Floppy::_stat(): delete m_mtool"; //kDebug(7104)<<"Floppy::_stat(): delete m_mtool";
delete m_mtool; delete m_mtool;
m_mtool=0; m_mtool=0;
//now mdir has finished //now mdir has finished
@ -551,7 +551,7 @@ StatInfo FloppyProtocol::_stat(const KUrl& url)
return info; return info;
} }
kDebug(7101)<<"Floppy::_stat(): parse stuff"; kDebug(7104)<<"Floppy::_stat(): parse stuff";
QString outputString(m_stdoutBuffer); QString outputString(m_stdoutBuffer);
QTextStream output(&outputString, QIODevice::ReadOnly); QTextStream output(&outputString, QIODevice::ReadOnly);
QString line; QString line;
@ -577,13 +577,13 @@ int FloppyProtocol::freeSpace(const KUrl& url)
QString floppyPath; QString floppyPath;
getDriveAndPath(path,drive,floppyPath); getDriveAndPath(path,drive,floppyPath);
//kDebug(7101)<<"Floppy::freeSpace(): delete m_mtool"; //kDebug(7104)<<"Floppy::freeSpace(): delete m_mtool";
delete m_mtool; delete m_mtool;
QStringList args; QStringList args;
args<<"mdir"<<"-a"<<drive; args<<"mdir"<<"-a"<<drive;
//kDebug(7101)<<"Floppy::freeSpace(): create m_mtool"; //kDebug(7104)<<"Floppy::freeSpace(): create m_mtool";
m_mtool=new Program(args); m_mtool=new Program(args);
if (!m_mtool->start()) if (!m_mtool->start())
@ -621,7 +621,7 @@ int FloppyProtocol::freeSpace(const KUrl& url)
} }
} while (!loopFinished); } while (!loopFinished);
//kDebug(7101)<<"Floppy::freeSpace(): delete m_mtool"; //kDebug(7104)<<"Floppy::freeSpace(): delete m_mtool";
delete m_mtool; delete m_mtool;
m_mtool=0; m_mtool=0;
//now mdir has finished //now mdir has finished
@ -639,7 +639,7 @@ int FloppyProtocol::freeSpace(const KUrl& url)
return -1; return -1;
} }
kDebug(7101)<<"Floppy::freeSpace(): parse stuff"; kDebug(7104)<<"Floppy::freeSpace(): parse stuff";
QString outputString(m_stdoutBuffer); QString outputString(m_stdoutBuffer);
QTextStream output(&outputString, QIODevice::ReadOnly); QTextStream output(&outputString, QIODevice::ReadOnly);
QString line; QString line;
@ -665,7 +665,7 @@ int FloppyProtocol::freeSpace(const KUrl& url)
void FloppyProtocol::stat( const KUrl & _url) void FloppyProtocol::stat( const KUrl & _url)
{ {
kDebug(7101)<<"Floppy::stat() "<<_url.path(); kDebug(7104)<<"Floppy::stat() "<<_url.path();
KUrl url(_url); KUrl url(_url);
QString path(url.path()); QString path(url.path());
@ -683,7 +683,7 @@ void FloppyProtocol::stat( const KUrl & _url)
createUDSEntry(info,entry); createUDSEntry(info,entry);
statEntry( entry ); statEntry( entry );
finished(); finished();
//kDebug(7101)<<"Floppy::stat(): ends"; //kDebug(7104)<<"Floppy::stat(): ends";
return; return;
} }
//otherwise the error() was already reported in _stat() //otherwise the error() was already reported in _stat()
@ -691,7 +691,7 @@ void FloppyProtocol::stat( const KUrl & _url)
void FloppyProtocol::mkdir( const KUrl& url, int) void FloppyProtocol::mkdir( const KUrl& url, int)
{ {
kDebug(7101)<<"FloppyProtocol::mkdir()"; kDebug(7104)<<"FloppyProtocol::mkdir()";
QString path(url.path()); QString path(url.path());
if ((path.isEmpty()) || (path=="/")) if ((path.isEmpty()) || (path=="/"))
@ -711,11 +711,11 @@ void FloppyProtocol::mkdir( const KUrl& url, int)
return; return;
} }
delete m_mtool; delete m_mtool;
//kDebug(7101)<<"Floppy::stat(): create args"; //kDebug(7104)<<"Floppy::stat(): create args";
QStringList args; QStringList args;
args<<"mmd"<<(drive+floppyPath); args<<"mmd"<<(drive+floppyPath);
kDebug(7101)<<"Floppy::mkdir(): executing: mmd -"<<(drive+floppyPath)<<"-"; kDebug(7104)<<"Floppy::mkdir(): executing: mmd -"<<(drive+floppyPath)<<"-";
m_mtool=new Program(args); m_mtool=new Program(args);
if (!m_mtool->start()) if (!m_mtool->start())
@ -762,7 +762,7 @@ void FloppyProtocol::mkdir( const KUrl& url, int)
void FloppyProtocol::del( const KUrl& url, bool isfile) void FloppyProtocol::del( const KUrl& url, bool isfile)
{ {
kDebug(7101)<<"FloppyProtocol::del()"; kDebug(7104)<<"FloppyProtocol::del()";
const QString path(url.path()); const QString path(url.path());
if ((path.isEmpty()) || (path=="/")) if ((path.isEmpty()) || (path=="/"))
@ -783,7 +783,7 @@ void FloppyProtocol::del( const KUrl& url, bool isfile)
} }
delete m_mtool; delete m_mtool;
//kDebug(7101)<<"Floppy::stat(): create args"; //kDebug(7104)<<"Floppy::stat(): create args";
QStringList args; QStringList args;
bool usingmdel; bool usingmdel;
@ -799,7 +799,7 @@ void FloppyProtocol::del( const KUrl& url, bool isfile)
usingmdel=false; usingmdel=false;
} }
kDebug(7101)<<"Floppy::del(): executing: " << (usingmdel ? QString("mdel") : QString("mrd") ) << "-"<<(drive+floppyPath)<<"-"; kDebug(7104)<<"Floppy::del(): executing: " << (usingmdel ? QString("mdel") : QString("mrd") ) << "-"<<(drive+floppyPath)<<"-";
m_mtool=new Program(args); m_mtool=new Program(args);
if (!m_mtool->start()) if (!m_mtool->start())
@ -849,7 +849,7 @@ void FloppyProtocol::rename( const KUrl &src, const KUrl &dest, KIO::JobFlags fl
QString srcPath(src.path()); QString srcPath(src.path());
QString destPath(dest.path()); QString destPath(dest.path());
kDebug(7101)<<"Floppy::rename() -"<<srcPath<<"- to -"<<destPath<<"-"; kDebug(7104)<<"Floppy::rename() -"<<srcPath<<"- to -"<<destPath<<"-";
if ((srcPath.isEmpty()) || (srcPath=="/")) if ((srcPath.isEmpty()) || (srcPath=="/"))
srcPath="/a/"; srcPath="/a/";
@ -876,7 +876,7 @@ void FloppyProtocol::rename( const KUrl &src, const KUrl &dest, KIO::JobFlags fl
} }
delete m_mtool; delete m_mtool;
//kDebug(7101)<<"Floppy::stat(): create args"; //kDebug(7104)<<"Floppy::stat(): create args";
QStringList args; QStringList args;
if (flags & KIO::Overwrite) if (flags & KIO::Overwrite)
@ -884,7 +884,7 @@ void FloppyProtocol::rename( const KUrl &src, const KUrl &dest, KIO::JobFlags fl
else else
args<<"mren"<<"-D"<<"s"<<(srcDrive+srcFloppyPath)<<(destDrive+destFloppyPath); args<<"mren"<<"-D"<<"s"<<(srcDrive+srcFloppyPath)<<(destDrive+destFloppyPath);
kDebug(7101)<<"Floppy::move(): executing: mren -"<<(srcDrive+srcFloppyPath)<<" "<<(destDrive+destFloppyPath); kDebug(7104)<<"Floppy::move(): executing: mren -"<<(srcDrive+srcFloppyPath)<<" "<<(destDrive+destFloppyPath);
m_mtool=new Program(args); m_mtool=new Program(args);
if (!m_mtool->start()) if (!m_mtool->start())
@ -932,7 +932,7 @@ void FloppyProtocol::rename( const KUrl &src, const KUrl &dest, KIO::JobFlags fl
void FloppyProtocol::get( const KUrl& url ) void FloppyProtocol::get( const KUrl& url )
{ {
QString path(url.path()); QString path(url.path());
kDebug(7101)<<"Floppy::get() -"<<path<<"-"; kDebug(7104)<<"Floppy::get() -"<<path<<"-";
if ((path.isEmpty()) || (path=="/")) if ((path.isEmpty()) || (path=="/"))
{ {
@ -959,11 +959,11 @@ void FloppyProtocol::get( const KUrl& url )
} }
delete m_mtool; delete m_mtool;
//kDebug(7101)<<"Floppy::stat(): create args"; //kDebug(7104)<<"Floppy::stat(): create args";
QStringList args; QStringList args;
args<<"mcopy"<<(drive+floppyPath)<<"-"; args<<"mcopy"<<(drive+floppyPath)<<"-";
kDebug(7101)<<"Floppy::get(): executing: mcopy -"<<(drive+floppyPath)<<"-"; kDebug(7104)<<"Floppy::get(): executing: mcopy -"<<(drive+floppyPath)<<"-";
m_mtool=new Program(args); m_mtool=new Program(args);
if (!m_mtool->start()) if (!m_mtool->start())
@ -990,7 +990,7 @@ void FloppyProtocol::get( const KUrl& url )
m_stdoutSize=0; m_stdoutSize=0;
if (readStdout()>0) if (readStdout()>0)
{ {
kDebug(7101)<<"Floppy::get(): m_stdoutSize:"<<m_stdoutSize; kDebug(7104)<<"Floppy::get(): m_stdoutSize:"<<m_stdoutSize;
data( QByteArray::fromRawData(m_stdoutBuffer, m_stdoutSize) ); data( QByteArray::fromRawData(m_stdoutBuffer, m_stdoutSize) );
} }
else else
@ -1011,13 +1011,13 @@ void FloppyProtocol::get( const KUrl& url )
} }
} while (!loopFinished); } while (!loopFinished);
//kDebug(7101)<<"Floppy::get(): deleting m_mtool"; //kDebug(7104)<<"Floppy::get(): deleting m_mtool";
delete m_mtool; delete m_mtool;
m_mtool=0; m_mtool=0;
if (errorOccured) if (errorOccured)
return; return;
//kDebug(7101)<<"Floppy::get(): finishing"; //kDebug(7104)<<"Floppy::get(): finishing";
data( QByteArray() ); data( QByteArray() );
finished(); finished();
} }
@ -1025,7 +1025,7 @@ void FloppyProtocol::get( const KUrl& url )
void FloppyProtocol::put( const KUrl& url, int , JobFlags flags ) void FloppyProtocol::put( const KUrl& url, int , JobFlags flags )
{ {
QString path(url.path()); QString path(url.path());
kDebug(7101)<<"Floppy::put() -"<<path<<"-"; kDebug(7104)<<"Floppy::put() -"<<path<<"-";
if ((path.isEmpty()) || (path=="/")) if ((path.isEmpty()) || (path=="/"))
{ {
@ -1048,14 +1048,14 @@ void FloppyProtocol::put( const KUrl& url, int , JobFlags flags )
return; return;
delete m_mtool; delete m_mtool;
//kDebug(7101)<<"Floppy::stat(): create args"; //kDebug(7104)<<"Floppy::stat(): create args";
QStringList args; QStringList args;
if (flags & KIO::Overwrite) if (flags & KIO::Overwrite)
args<<"mcopy"<<"-o"<<"-"<<(drive+floppyPath); args<<"mcopy"<<"-o"<<"-"<<(drive+floppyPath);
else else
args<<"mcopy"<<"-s"<<"-"<<(drive+floppyPath); args<<"mcopy"<<"-s"<<"-"<<(drive+floppyPath);
kDebug(7101)<<"Floppy::put(): executing: mcopy -"<<(drive+floppyPath)<<"-"; kDebug(7104)<<"Floppy::put(): executing: mcopy -"<<(drive+floppyPath)<<"-";
m_mtool=new Program(args); m_mtool=new Program(args);
if (!m_mtool->start()) if (!m_mtool->start())
@ -1077,7 +1077,7 @@ void FloppyProtocol::put( const KUrl& url, int , JobFlags flags )
{ {
bool stdoutEvent; bool stdoutEvent;
bool stderrEvent; bool stderrEvent;
kDebug(7101)<<"Floppy::put(): select()..."; kDebug(7104)<<"Floppy::put(): select()...";
m_mtool->select(0,100,stdoutEvent, stderrEvent); m_mtool->select(0,100,stdoutEvent, stderrEvent);
if (stdoutEvent) if (stdoutEvent)
{ {
@ -1091,19 +1091,19 @@ void FloppyProtocol::put( const KUrl& url, int , JobFlags flags )
else else
if (stopAfterError(url,drive)) if (stopAfterError(url,drive))
result=-1; result=-1;
kDebug(7101)<<"Floppy::put(): error: result=="<<result; kDebug(7104)<<"Floppy::put(): error: result=="<<result;
} }
else else
{ {
QByteArray buffer; QByteArray buffer;
dataReq(); // Request for data dataReq(); // Request for data
//kDebug(7101)<<"Floppy::put(): after dataReq()"; //kDebug(7104)<<"Floppy::put(): after dataReq()";
result = readData( buffer ); result = readData( buffer );
//kDebug(7101)<<"Floppy::put(): after readData(), read "<<result<<" bytes"; //kDebug(7104)<<"Floppy::put(): after readData(), read "<<result<<" bytes";
if (result > 0) if (result > 0)
{ {
bytesRead+=result; bytesRead+=result;
kDebug(7101)<<"Floppy::put() bytesRead: "<<bytesRead<<" space: "<<freeSpaceLeft; kDebug(7104)<<"Floppy::put() bytesRead: "<<bytesRead<<" space: "<<freeSpaceLeft;
if (bytesRead>freeSpaceLeft) if (bytesRead>freeSpaceLeft)
{ {
result=0; result=0;
@ -1111,9 +1111,9 @@ void FloppyProtocol::put( const KUrl& url, int , JobFlags flags )
} }
else else
{ {
//kDebug(7101)<<"Floppy::put(): writing..."; //kDebug(7104)<<"Floppy::put(): writing...";
result=::write(m_mtool->stdinFD(),buffer.data(), buffer.size()); result=::write(m_mtool->stdinFD(),buffer.data(), buffer.size());
kDebug(7101)<<"Floppy::put(): after write(), wrote "<<result<<" bytes"; kDebug(7104)<<"Floppy::put(): after write(), wrote "<<result<<" bytes";
} }
} }
} }

View file

@ -85,14 +85,14 @@ bool Program::start()
struct timeval tv; struct timeval tv;
//wait up to five seconds //wait up to five seconds
kDebug(7101)<<"**** waiting for notification"; kDebug(7104)<<"**** waiting for notification";
//0.2 sec //0.2 sec
tv.tv_sec=0; tv.tv_sec=0;
tv.tv_usec=1000*200; tv.tv_usec=1000*200;
int result=::select(notificationPipe[0]+1,&notifSet,0,0,&tv); int result=::select(notificationPipe[0]+1,&notifSet,0,0,&tv);
/* if (result<1) /* if (result<1)
{ {
kDebug(7101)<<"**** waiting for notification: failed "<<result; kDebug(7104)<<"**** waiting for notification: failed "<<result;
return false; return false;
} }
else*/ else*/
@ -104,7 +104,7 @@ bool Program::start()
if (result>0) if (result>0)
return false; return false;
}; };
kDebug(7101)<<"**** waiting for notification: succeeded"<<result; kDebug(7104)<<"**** waiting for notification: succeeded"<<result;
return true; return true;
} }
else if (m_pid==-1) else if (m_pid==-1)