KIO::filesize_t K3b::filesize( const KURL& url ) { if( url.isLocalFile() ) { k3b_struct_stat buf; if ( !k3b_stat( QFile::encodeName( url.path() ), &buf ) ) { return (KIO::filesize_t)buf.st_size; } } KIO::UDSEntry uds; KIO::NetAccess::stat( url, uds, 0 ); for( KIO::UDSEntry::const_iterator it = uds.begin(); it != uds.end(); ++it ) { if( (*it).m_uds == KIO::UDS_SIZE ) { return (*it).m_long; } } return ( KIO::filesize_t )0; }
KURL K3b::convertToLocalUrl( const KURL& url ) { if( !url.isLocalFile() ) { #if KDE_IS_VERSION(3,4,91) return KIO::NetAccess::mostLocalURL( url, 0 ); #else #ifndef UDS_LOCAL_PATH #define UDS_LOCAL_PATH (72 | KIO::UDS_STRING) #else using namespace KIO; #endif KIO::UDSEntry e; if( KIO::NetAccess::stat( url, e, 0 ) ) { const KIO::UDSEntry::ConstIterator end = e.end(); for( KIO::UDSEntry::ConstIterator it = e.begin(); it != end; ++it ) { if( (*it).m_uds == UDS_LOCAL_PATH && !(*it).m_str.isEmpty() ) return KURL::fromPathOrURL( (*it).m_str ); } } #endif } return url; }
/* * slotEntries * * Receive files listed by KIO and call addMatches() */ void KURLCompletion::slotEntries(KIO::Job *, const KIO::UDSEntryList &entries) { QStringList matches; KIO::UDSEntryListConstIterator it = entries.begin(); KIO::UDSEntryListConstIterator end = entries.end(); QString filter = d->list_urls_filter; int filter_len = filter.length(); // Iterate over all files // for(; it != end; ++it) { QString name; QString url; bool is_exe = false; bool is_dir = false; KIO::UDSEntry e = *it; KIO::UDSEntry::ConstIterator it_2 = e.begin(); for(; it_2 != e.end(); it_2++) { switch((*it_2).m_uds) { case KIO::UDS_NAME: name = (*it_2).m_str; break; case KIO::UDS_ACCESS: is_exe = ((*it_2).m_long & MODE_EXE) != 0; break; case KIO::UDS_FILE_TYPE: is_dir = ((*it_2).m_long & S_IFDIR) != 0; break; case KIO::UDS_URL: url = (*it_2).m_str; break; } } if(!url.isEmpty()) { // kdDebug() << "KURLCompletion::slotEntries url: " << url << endl; name = KURL(url).fileName(); } // kdDebug() << "KURLCompletion::slotEntries name: " << name << endl; if(name[0] == '.' && (d->list_urls_no_hidden || name.length() == 1 || (name.length() == 2 && name[1] == '.'))) continue; if(d->mode == DirCompletion && !is_dir) continue; if(filter_len == 0 || name.left(filter_len) == filter) { if(is_dir) name.append('/'); if(is_exe || !d->list_urls_only_exe) matches.append(name); } } addMatches(matches); }