[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kio_virtualfile/kioslave/file
From: Allan Sandfeld Jensen <kde () carewolf ! com>
Date: 2006-07-06 16:52:10
Message-ID: 1152204730.686463.11543.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 559136 by carewolf:
file ioslave
M +31 -11 file.cc
--- branches/work/kio_virtualfile/kioslave/file/file.cc #559135:559136
@@ -62,6 +62,7 @@
#include <string.h>
#endif
+#include <QByteArray>
#include <qdatetime.h>
#include <qregexp.h>
@@ -84,6 +85,7 @@
#endif
#include <kstandarddirs.h>
+#include <kio/connection.h>
#include <kio/ioslave_defaults.h>
#include <kde_file.h>
#include <kglobal.h>
@@ -242,6 +244,7 @@
void FileProtocol::get( const KUrl& url )
{
+ kDebug( 7101 ) << "File::get" << endl;
if (!url.isLocalFile()) {
KUrl redir(url);
redir.setProtocol(config()->readEntry("DefaultRemoteProtocol", "smb"));
@@ -341,6 +344,8 @@
void FileProtocol::open( const KUrl& url )
{
+ kDebug( 7101 ) << "File::open" << endl;
+
QByteArray _path( QFile::encodeName(url.path()));
KDE_struct_stat buff;
if ( KDE_stat( _path.data(), &buff ) == -1 ) {
@@ -372,23 +377,31 @@
totalSize( buff.st_size );
- emit file(fd);
+ emit file((void*)fd);
+ position( 0 );
QByteArray array;
// Command-loop:
int cmd = CMD_NONE;
while (true) {
- QByteArray data;
- appconn->read(&cmd, data);
- QDataStream stream( data );
- switch( command ) {
+ kDebug( 7101 ) << "File::open -- loop" << endl;
+ QByteArray args;
+ int stat = appconn->read(&cmd, args);
+ if ( stat == -1 )
+ { // error
+ kDebug( 7101 ) << "File::open -- connection erro" << endl;
+ break;
+ }
+ QDataStream stream( args );
+ switch( cmd ) {
case CMD_READ: {
- char buffer[ bytes ];
+ kDebug( 7101 ) << "File::open -- read" << endl;
int bytes;
stream >> bytes;
+ char buffer[ bytes ];
::read(fd, buffer, bytes);
- array = array.fromRawData(buffer, n);
+ array = array.fromRawData(buffer, bytes);
data( array );
array.clear();
break;
@@ -406,17 +419,24 @@
case CMD_SEEK: {
int offset;
stream >> offset;
- KDE_seek(fd, offset);
+ KDE_lseek(fd, offset, SEEK_SET);
+ position( offset );
+ break;
}
+ case CMD_NONE:
+ kDebug( 7101 ) << "File::open -- none " << endl;
+ continue;
case CMD_CLOSE:
- close( fd );
- finished();
break;
default:
- // wrong command
+ kDebug( 7101 ) << "File::open -- invalid command: " << cmd << endl;
+ cmd = CMD_CLOSE;
+ break;
}
if (cmd == CMD_CLOSE) break;
}
+ close( fd );
+ finished();
}
static int
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic