kioslave - listDir function (newbie)

Brad Hards bhards at bigpond.net.au
Thu Oct 10 14:37:45 BST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 10 Oct 2002 08:01, Brad Hards wrote:
> On Wed, 9 Oct 2002 18:56, David Faure wrote:
> > Your stat() implementation looks fine, but if you want to see entries in
> > a directory listing, you need to implement listDir().
>
> Thanks. Now implemented, and my trivial example is now ready for expansion
> to do something useful :)
OK, I'm now parsing the output from rsync. It basically looks like:
drwxr-sr-x        4096 2002/04/10 16:42:23 .
- -rw-r--r--         159 2002/03/13 11:24:30 .message
- -rw-r--r--       17982 1997/12/27 15:26:26 COPYING
- -r--r--r--        1320 2002/04/02 12:12:12 NEWS
- -rw-r--r--        7211 2002/01/03 18:19:51 README
drwxr-sr-x        4096 2001/10/16 00:59:19 binaries
- -rw-r--r--      466705 2002/01/03 18:20:36 cvs.log

The code looks like:

void RsyncProtocol::parseDirStream()
{
  UDSEntry entry;
  UDSAtom atom;
  QString tmp;
  long val;

  // split up into lines
  QStringList files(QStringList::split("\n", fileStream));

  for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {

    // split up each line
    atom.m_uds = KIO::UDS_NAME;
    tmp = (*it).mid( 43 ) + " "; // or + "/"
^^^^^^^^^This line problematical.^^^^^^
    atom.m_str = tmp;
    entry.append( atom );

    atom.m_uds = KIO::UDS_FILE_TYPE;
    tmp = (*it).left(10);
    if (tmp[0] == 'd')
      atom.m_long = S_IFDIR;
    else
      atom.m_long = S_IFREG;
    entry.append( atom );

    atom.m_uds = KIO::UDS_SIZE;
    tmp = (*it).mid( 11, 11 );
    sscanf(tmp.local8Bit(), "%ld", &val);
    kdDebug() << "kio_rsync::listDir" << val << endl ;
    atom.m_long = val ;
    entry.append(atom);

    listEntry( entry, false );
  }

  // One more to emit the list
  listEntry( entry, true );

}

void RsyncProtocol::listDir(const KURL& url )
{
  // Reset the stream
  *myStdStream="";

  myKProcess = new KProcess();
  *myKProcess << "rsync" << QString(url.prettyURL());
  connect(myKProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
          this, SLOT(slotGetStdOutput(KProcess *, char *, int)));

  myKProcess->start(KProcess::Block, KProcess::All);

  parseDirStream();

  finished();
  delete myKProcess;
  return;
}

It only works with something on the end (or beginning) of the filename. Of 
course, that completely breaks the directory system.  If I don't have that 
space, I'm hitting the assert  ( Q_ASSERT( !dir->rootItem ) ) in 
kdirlister.cpp (line 802).

I'm confused as to what this is missing. What does the listDir function need 
to provide, except for listEntry's? I tried adding a dummy ".." type entry - 
no joy. Is there any documentation beyond the KIO API reference 
(http://developer.kde.org/documentation/library/cvs-api/classref/kio/KIO.html)?

If that wasn't enough, I'm also getting the same size for every file: see 
http://www.cuneata.net/rsync-kio.html for an example (with the space hack).

This is a _lot_ tougher than I expected :(

Brad
- --
http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9pYKpW6pHgIdAuOMRAv15AJ9l95U8ZjViPd3Ng1h57mr9STLqhQCeMZ7D
gPaup++QLLygn9ftrkGTQIA=
=1hWK
-----END PGP SIGNATURE-----





More information about the kfm-devel mailing list