[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Newbie: Why does KMainWindow::show() hang?!
From:       Weinzierl Stefan <Stefan () Weinzierl-Stefan ! de>
Date:       2005-04-26 21:41:47
Message-ID: 426EB59B.5050905 () Weinzierl-Stefan ! de
[Download RAW message or body]

Felix schrieb:
[...]
> void kbinfmtView::open( const KURL& url ) {
>     char buf[ 10240 ];
>     std::ifstream in( url.path(), std::ios::binary );
>     std::vector<char> fcontent;
>     int bufsize;
>     std::cout << "reading " << url.path() << std::endl;
>     while ( in.good() && ( bufsize = in.readsome( buf, 10240 ) ) > 0 ) {
>         int size = fcontent.size();
>         fcontent.resize( size + bufsize );
>         for ( int i = 0; i < bufsize; i++ )
>             fcontent[ i + size ] = buf[ i ];
>         emit signalChangeStatusbar( QString("Reading... (") +
> QString::number( size ) + " bytes)" );
>         std::cout << "reading ... " << size << std::endl;
>     }
>     if (in.good())
>         emit signalChangeStatusbar( "Done." );
> 	else
>         emit signalChangeStatusbar( "Error reading file." );
>     fileTable->setContents( fcontent );
> }
> 
> void kbinfmtView::save( const KURL& url) {
>     char buf[ 10240 ];
>     std::ofstream out( url.path(), std::ios::binary );
>     std::vector<char> fcontent = fileTable->getContents();
>     int fcsize = fcontent.size();
>     int idx = 0;
>     while ( out.good() && (idx < fcsize)) {
>         int i;
>         for (int i = idx; (i < fcsize) && (i - idx < 10240); i++)
> 	    buf[i-idx] = fcontent[i];
> 	out.write(buf, i - idx);
> 	idx += i;
>         emit signalChangeStatusbar( "Saving... (" + QString::number( idx ) +
>  " bytes)" );
>     }
>     if (out.good())
>         emit signalChangeStatusbar( "Done." );
> 	else
>         emit signalChangeStatusbar( "Error writing file." );
>     fileTable->setContents( fcontent );
> }

Independed from your problem: Have you ever looked at KIO::storedGet and 
KIO::storedPut?

Stefan
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic