• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kio
 

kio/kio

  • kio
  • kio
kfileitem.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 1999 David Faure <faure@kde.org>
3  2001 Carsten Pfeiffer <pfeiffer@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 // $Id$
21 
22 #include <sys/time.h>
23 #include <pwd.h>
24 #include <grp.h>
25 #include <sys/types.h>
26 
27 #include <assert.h>
28 #include <unistd.h>
29 
30 #include "kfileitem.h"
31 
32 #include <tqdir.h>
33 #include <tqfile.h>
34 #include <tqmap.h>
35 #include <tqstylesheet.h>
36 
37 #include <kdebug.h>
38 #include <kfilemetainfo.h>
39 #include <ksambashare.h>
40 #include <knfsshare.h>
41 #include <kglobal.h>
42 #include <kglobalsettings.h>
43 #include <kiconloader.h>
44 #include <klargefile.h>
45 #include <klocale.h>
46 #include <kmimetype.h>
47 #include <krun.h>
48 
49 class KFileItem::KFileItemPrivate {
50  public:
51  KFileItemPrivate() : commentCached(false) {}
52 
53  public:
54  TQString iconName;
55  TQString comment;
56  bool commentCached;
57 };
58 
59 KFileItem::KFileItem( const KIO::UDSEntry& _entry, const KURL& _url,
60  bool _determineMimeTypeOnDemand, bool _urlIsDirectory ) :
61  m_entry( _entry ),
62  m_url( _url ),
63  m_pMimeType( 0 ),
64  m_fileMode( KFileItem::Unknown ),
65  m_permissions( KFileItem::Unknown ),
66  m_bMarked( false ),
67  m_bLink( false ),
68  m_bIsLocalURL( _url.isLocalFile() ),
69  m_bMimeTypeKnown( false ),
70  m_hidden( Auto ),
71  d(0)
72 {
73  readUDSEntry( _urlIsDirectory );
74  init( _determineMimeTypeOnDemand );
75 }
76 
77 KFileItem::KFileItem( mode_t _mode, mode_t _permissions, const KURL& _url, bool _determineMimeTypeOnDemand ) :
78  m_entry(), // warning !
79  m_url( _url ),
80  m_strName( _url.fileName() ),
81  m_strText( KIO::decodeFileName( m_strName ) ),
82  m_pMimeType( 0 ),
83  m_fileMode ( _mode ),
84  m_permissions( _permissions ),
85  m_bMarked( false ),
86  m_bLink( false ),
87  m_bIsLocalURL( _url.isLocalFile() ),
88  m_bMimeTypeKnown( false ),
89  m_hidden( Auto ),
90  d(0)
91 {
92  init( _determineMimeTypeOnDemand );
93 }
94 
95 KFileItem::KFileItem( const KURL &url, const TQString &mimeType, mode_t mode )
96 : m_url( url ),
97  m_strName( url.fileName() ),
98  m_strText( KIO::decodeFileName( m_strName ) ),
99  m_pMimeType( 0 ),
100  m_fileMode( mode ),
101  m_permissions( KFileItem::Unknown ),
102  m_bMarked( false ),
103  m_bLink( false ),
104  m_bIsLocalURL( url.isLocalFile() ),
105  m_bMimeTypeKnown( !mimeType.isEmpty() ),
106  m_hidden( Auto ),
107  d(0)
108 {
109  if (m_bMimeTypeKnown)
110  m_pMimeType = KMimeType::mimeType( mimeType );
111 
112  init( false );
113 }
114 
115 KFileItem::KFileItem( const KFileItem & item ) :
116  d(0)
117 {
118  assign( item );
119 }
120 
121 KFileItem& KFileItem::operator=( const KFileItem & item )
122 {
123  assign( item );
124  return *this;
125 }
126 
127 KFileItem::~KFileItem()
128 {
129  delete d;
130 }
131 
132 void KFileItem::init( bool _determineMimeTypeOnDemand )
133 {
134  m_access = TQString::null;
135  m_size = (KIO::filesize_t) -1;
136  // metaInfo = KFileMetaInfo();
137  for ( int i = 0; i < NumFlags; i++ )
138  m_time[i] = (time_t) -1;
139 
140  // determine mode and/or permissions if unknown
141  if ( m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown )
142  {
143  mode_t mode = 0;
144  if ( m_url.isLocalFile() )
145  {
146  /* directories may not have a slash at the end if
147  * we want to stat() them; it requires that we
148  * change into it .. which may not be allowed
149  * stat("/is/unaccessible") -> rwx------
150  * stat("/is/unaccessible/") -> EPERM H.Z.
151  * This is the reason for the -1
152  */
153  KDE_struct_stat buf;
154  TQCString path = TQFile::encodeName(m_url.path( -1 ));
155  if ( KDE_lstat( path.data(), &buf ) == 0 )
156  {
157  mode = buf.st_mode;
158  if ( S_ISLNK( mode ) )
159  {
160  m_bLink = true;
161  if ( KDE_stat( path.data(), &buf ) == 0 )
162  mode = buf.st_mode;
163  else // link pointing to nowhere (see kio/file/file.cc)
164  mode = (S_IFMT-1) | S_IRWXU | S_IRWXG | S_IRWXO;
165  }
166  // While we're at it, store the times
167  m_time[ Modification ] = buf.st_mtime;
168  m_time[ Access ] = buf.st_atime;
169  if ( m_fileMode == KFileItem::Unknown )
170  m_fileMode = mode & S_IFMT; // extract file type
171  if ( m_permissions == KFileItem::Unknown )
172  m_permissions = mode & 07777; // extract permissions
173  }
174  }
175  }
176 
177  // determine the mimetype
178  if (!m_pMimeType && !m_url.isEmpty())
179  {
180  bool accurate = false;
181  bool isLocalURL;
182  KURL url = mostLocalURL(isLocalURL);
183 
184  m_pMimeType = KMimeType::findByURL( url, m_fileMode, isLocalURL,
185  // use fast mode if not mimetype on demand
186  _determineMimeTypeOnDemand, &accurate );
187  //kdDebug() << "finding mimetype for " << url.url() << " : " << m_pMimeType->name() << endl;
188  // if we didn't use fast mode, or if we got a result, then this is the mimetype
189  // otherwise, determineMimeType will be able to do better.
190  m_bMimeTypeKnown = (!_determineMimeTypeOnDemand) || accurate;
191  }
192 }
193 
194 void KFileItem::readUDSEntry( bool _urlIsDirectory )
195 {
196  // extract the mode and the filename from the KIO::UDS Entry
197  bool UDS_URL_seen = false;
198 
199  if (&m_entry == NULL) return;
200 
201  KIO::UDSEntry::ConstIterator it = m_entry.begin();
202  for( ; it != m_entry.end(); ++it ) {
203  switch ((*it).m_uds) {
204 
205  case KIO::UDS_FILE_TYPE:
206  m_fileMode = (mode_t)((*it).m_long);
207  break;
208 
209  case KIO::UDS_ACCESS:
210  m_permissions = (mode_t)((*it).m_long);
211  break;
212 
213  case KIO::UDS_USER:
214  m_user = ((*it).m_str);
215  break;
216 
217  case KIO::UDS_GROUP:
218  m_group = ((*it).m_str);
219  break;
220 
221  case KIO::UDS_NAME:
222  m_strName = (*it).m_str;
223  m_strText = KIO::decodeFileName( m_strName );
224  break;
225 
226  case KIO::UDS_URL:
227  UDS_URL_seen = true;
228  m_url = KURL((*it).m_str);
229  if ( m_url.isLocalFile() )
230  m_bIsLocalURL = true;
231  break;
232 
233  case KIO::UDS_MIME_TYPE:
234  m_pMimeType = KMimeType::mimeType((*it).m_str);
235  m_bMimeTypeKnown = true;
236  break;
237 
238  case KIO::UDS_GUESSED_MIME_TYPE:
239  m_guessedMimeType = (*it).m_str;
240  break;
241 
242  case KIO::UDS_LINK_DEST:
243  m_bLink = !(*it).m_str.isEmpty(); // we don't store the link dest
244  break;
245 
246  case KIO::UDS_ICON_NAME:
247  if ( !d ) {
248  d = new KFileItemPrivate();
249  }
250  d->iconName = (*it).m_str;
251  break;
252 
253  case KIO::UDS_HIDDEN:
254  if ( (*it).m_long )
255  m_hidden = Hidden;
256  else
257  m_hidden = Shown;
258  break;
259  }
260  }
261 
262  // avoid creating these QStrings again and again
263  static const TQString& dot = KGlobal::staticQString(".");
264  if ( _urlIsDirectory && !UDS_URL_seen && !m_strName.isEmpty() && m_strName != dot )
265  m_url.addPath( m_strName );
266 }
267 
268 void KFileItem::refresh()
269 {
270  m_fileMode = KFileItem::Unknown;
271  m_permissions = KFileItem::Unknown;
272  m_pMimeType = 0L;
273  m_user = TQString::null;
274  m_group = TQString::null;
275  m_metaInfo = KFileMetaInfo();
276  m_hidden = Auto;
277 
278  // Basically, we can't trust any information we got while listing.
279  // Everything could have changed...
280  // Clearing m_entry makes it possible to detect changes in the size of the file,
281  // the time information, etc.
282  m_entry = KIO::UDSEntry();
283  init( false );
284 }
285 
286 void KFileItem::refreshMimeType()
287 {
288  if ( d ) {
289  d->iconName = TQString::null;
290  d->comment = TQString::null;
291  d->commentCached = false;
292  }
293  m_pMimeType = 0L;
294  init( false ); // Will determine the mimetype
295 }
296 
297 void KFileItem::setURL( const KURL &url )
298 {
299  m_url = url;
300  setName( url.fileName() );
301 }
302 
303 void KFileItem::setName( const TQString& name )
304 {
305  m_strName = name;
306  m_strText = KIO::decodeFileName( m_strName );
307 }
308 
309 TQString KFileItem::linkDest() const
310 {
311  if (&m_entry == NULL) return TQString::null;
312 
313  // Extract it from the KIO::UDSEntry
314  KIO::UDSEntry::ConstIterator it = m_entry.begin();
315  for( ; it != m_entry.end(); ++it )
316  if ( (*it).m_uds == KIO::UDS_LINK_DEST )
317  return (*it).m_str;
318  // If not in the KIO::UDSEntry, or if UDSEntry empty, use readlink() [if local URL]
319  if ( m_bIsLocalURL )
320  {
321  char buf[1000];
322  int n = readlink( TQFile::encodeName(m_url.path( -1 )), buf, sizeof(buf)-1 );
323  if ( n != -1 )
324  {
325  buf[ n ] = 0;
326  return TQFile::decodeName( buf );
327  }
328  }
329  return TQString::null;
330 }
331 
332 TQString KFileItem::localPath() const
333 {
334  if ( m_bIsLocalURL )
335  {
336  return m_url.path();
337  }
338  else
339  {
340  if (&m_entry == NULL) return TQString::null;
341 
342  // Extract the local path from the KIO::UDSEntry
343  KIO::UDSEntry::ConstIterator it = m_entry.begin();
344  const KIO::UDSEntry::ConstIterator end = m_entry.end();
345  for( ; it != end; ++it )
346  if ( (*it).m_uds == KIO::UDS_LOCAL_PATH )
347  return (*it).m_str;
348  }
349 
350  return TQString::null;
351 }
352 
353 KIO::filesize_t KFileItem::size(bool &exists) const
354 {
355  exists = true;
356  if ( m_size != (KIO::filesize_t) -1 )
357  return m_size;
358 
359  if (&m_entry == NULL) return 0L;
360 
361  // Extract it from the KIO::UDSEntry
362  KIO::UDSEntry::ConstIterator it = m_entry.begin();
363  for( ; it != m_entry.end(); ++it )
364  if ( (*it).m_uds == KIO::UDS_SIZE ) {
365  m_size = (*it).m_long;
366  return m_size;
367  }
368  // If not in the KIO::UDSEntry, or if UDSEntry empty, use stat() [if local URL]
369  if ( m_bIsLocalURL )
370  {
371  KDE_struct_stat buf;
372  if ( KDE_stat( TQFile::encodeName(m_url.path( -1 )), &buf ) == 0 )
373  return buf.st_size;
374  }
375  exists = false;
376  return 0L;
377 }
378 
379 bool KFileItem::hasExtendedACL() const
380 {
381  if (&m_entry == NULL) return false;
382  KIO::UDSEntry::ConstIterator it = m_entry.begin();
383  for( ; it != m_entry.end(); it++ )
384  if ( (*it).m_uds == KIO::UDS_EXTENDED_ACL ) {
385  return true;
386  }
387  return false;
388 }
389 
390 KACL KFileItem::ACL() const
391 {
392  if ( hasExtendedACL() ) {
393  if (&m_entry == NULL) return KACL( m_permissions );
394 
395  // Extract it from the KIO::UDSEntry
396  KIO::UDSEntry::ConstIterator it = m_entry.begin();
397  for( ; it != m_entry.end(); ++it )
398  if ( (*it).m_uds == KIO::UDS_ACL_STRING )
399  return KACL((*it).m_str);
400  }
401  // create one from the basic permissions
402  return KACL( m_permissions );
403 }
404 
405 KACL KFileItem::defaultACL() const
406 {
407  if (&m_entry == NULL) return KACL();
408 
409  // Extract it from the KIO::UDSEntry
410  KIO::UDSEntry::ConstIterator it = m_entry.begin();
411  for( ; it != m_entry.end(); ++it )
412  if ( (*it).m_uds == KIO::UDS_DEFAULT_ACL_STRING )
413  return KACL((*it).m_str);
414  return KACL();
415 }
416 
417 KIO::filesize_t KFileItem::size() const
418 {
419  bool exists;
420  return size(exists);
421 }
422 
423 time_t KFileItem::time( unsigned int which ) const
424 {
425  bool hasTime;
426  return time(which, hasTime);
427 }
428 time_t KFileItem::time( unsigned int which, bool &hasTime ) const
429 {
430  hasTime = true;
431  unsigned int mappedWhich = 0;
432 
433  switch( which ) {
434  case KIO::UDS_MODIFICATION_TIME:
435  mappedWhich = Modification;
436  break;
437  case KIO::UDS_ACCESS_TIME:
438  mappedWhich = Access;
439  break;
440  case KIO::UDS_CREATION_TIME:
441  mappedWhich = Creation;
442  break;
443  }
444 
445  if ( m_time[mappedWhich] != (time_t) -1 )
446  return m_time[mappedWhich];
447 
448  if (&m_entry == NULL) return static_cast<time_t>(0);
449 
450  // Extract it from the KIO::UDSEntry
451  KIO::UDSEntry::ConstIterator it = m_entry.begin();
452  for( ; it != m_entry.end(); ++it )
453  if ( (*it).m_uds == which ) {
454  m_time[mappedWhich] = static_cast<time_t>((*it).m_long);
455  return m_time[mappedWhich];
456  }
457 
458  // If not in the KIO::UDSEntry, or if UDSEntry empty, use stat() [if local URL]
459  if ( m_bIsLocalURL )
460  {
461  KDE_struct_stat buf;
462  if ( KDE_stat( TQFile::encodeName(m_url.path(-1)), &buf ) == 0 )
463  {
464  if(which == KIO::UDS_CREATION_TIME) {
465  // We can't determine creation time for local files
466  hasTime = false;
467  m_time[mappedWhich] = static_cast<time_t>(0);
468  return m_time[mappedWhich];
469  }
470  m_time[mappedWhich] = (which == KIO::UDS_MODIFICATION_TIME) ?
471  buf.st_mtime :
472  /* which == KIO::UDS_ACCESS_TIME)*/
473  buf.st_atime;
474  return m_time[mappedWhich];
475  }
476  }
477  hasTime = false;
478  return static_cast<time_t>(0);
479 }
480 
481 
482 TQString KFileItem::user() const
483 {
484  if ( m_user.isEmpty() && m_bIsLocalURL )
485  {
486  KDE_struct_stat buff;
487  if ( KDE_lstat( TQFile::encodeName(m_url.path( -1 )), &buff ) == 0) // get uid/gid of the link, if it's a link
488  {
489  struct passwd *user = getpwuid( buff.st_uid );
490  if ( user != 0L )
491  m_user = TQString::fromLocal8Bit(user->pw_name);
492  }
493  }
494  return m_user;
495 }
496 
497 TQString KFileItem::group() const
498 {
499 #ifdef Q_OS_UNIX
500  if (m_group.isEmpty() && m_bIsLocalURL )
501  {
502  KDE_struct_stat buff;
503  if ( KDE_lstat( TQFile::encodeName(m_url.path( -1 )), &buff ) == 0) // get uid/gid of the link, if it's a link
504  {
505  struct group *ge = getgrgid( buff.st_gid );
506  if ( ge != 0L ) {
507  m_group = TQString::fromLocal8Bit(ge->gr_name);
508  if (m_group.isEmpty())
509  m_group.sprintf("%d",ge->gr_gid);
510  } else
511  m_group.sprintf("%d",buff.st_gid);
512  }
513  }
514 #endif
515  return m_group;
516 }
517 
518 TQString KFileItem::mimetype() const
519 {
520  KFileItem * that = const_cast<KFileItem *>(this);
521  return that->determineMimeType()->name();
522 }
523 
524 TQString KFileItem::mimetypeFast() const
525 {
526  if (isMimeTypeKnown()) {
527  return mimetype();
528  }
529  else {
530  return m_pMimeType->name();
531  }
532 }
533 
534 KMimeType::Ptr KFileItem::mimeTypePtrFast()
535 {
536  return m_pMimeType;
537 }
538 
539 KMimeType::Ptr KFileItem::determineMimeType()
540 {
541  if ( !m_pMimeType || !m_bMimeTypeKnown )
542  {
543  bool isLocalURL;
544  KURL url = mostLocalURL(isLocalURL);
545 
546  m_pMimeType = KMimeType::findByURL( url, m_fileMode, isLocalURL );
547  //kdDebug() << "finding mimetype for " << url.url() << " : " << m_pMimeType->name() << endl;
548  m_bMimeTypeKnown = true;
549  }
550 
551  return m_pMimeType;
552 }
553 
554 bool KFileItem::isMimeTypeKnown() const
555 {
556  // The mimetype isn't known if determineMimeType was never called (on-demand determination)
557  // or if this fileitem has a guessed mimetype (e.g. ftp symlink) - in which case
558  // it always remains "not fully determined"
559  return m_bMimeTypeKnown && m_guessedMimeType.isEmpty();
560 }
561 
562 TQString KFileItem::mimeComment()
563 {
564  if (d && (d->commentCached)) return d->comment;
565 
566  KMimeType::Ptr mType = determineMimeType();
567 
568  bool isLocalURL;
569  KURL url = mostLocalURL(isLocalURL);
570 
571  TQString comment = mType->comment( url, isLocalURL );
572  //kdDebug() << "finding comment for " << url.url() << " : " << m_pMimeType->name() << endl;
573  if ( !d ) {
574  d = new KFileItemPrivate();
575  }
576  if (!comment.isEmpty()) {
577  d->comment = comment;
578  d->commentCached = true;
579  }
580  else {
581  d->comment = mType->name();
582  d->commentCached = true;
583  }
584 
585  return d->comment;
586 }
587 
588 TQString KFileItem::iconName()
589 {
590  if (d && (!d->iconName.isEmpty())) return d->iconName;
591 
592  bool isLocalURL;
593  KURL url = mostLocalURL(isLocalURL);
594 
595  //kdDebug() << "finding icon for " << url.url() << " : " << m_pMimeType->name() << endl;
596  return determineMimeType()->icon(url, isLocalURL);
597 }
598 
599 int KFileItem::overlays() const
600 {
601  int _state = 0;
602  if ( m_bLink )
603  _state |= KIcon::LinkOverlay;
604 
605  if ( !S_ISDIR( m_fileMode ) // Locked dirs have a special icon, use the overlay for files only
606  && !isReadable())
607  _state |= KIcon::LockOverlay;
608 
609  if ( isHidden() )
610  _state |= KIcon::HiddenOverlay;
611 
612  if( S_ISDIR( m_fileMode ) && m_bIsLocalURL)
613  {
614  if (KSambaShare::instance()->isDirectoryShared( m_url.path() ) ||
615  KNFSShare::instance()->isDirectoryShared( m_url.path() ))
616  {
617  //kdDebug()<<"KFileShare::isDirectoryShared : "<<m_url.path()<<endl;
618  _state |= KIcon::ShareOverlay;
619  }
620  }
621 
622  if ( m_pMimeType->name() == "application/x-gzip" && m_url.fileName().right(3) == ".gz" )
623  _state |= KIcon::ZipOverlay;
624  return _state;
625 }
626 
627 TQPixmap KFileItem::pixmap( int _size, int _state ) const
628 {
629  if (d && (!d->iconName.isEmpty()))
630  return DesktopIcon(d->iconName,_size,_state);
631 
632  if ( !m_pMimeType )
633  {
634  static const TQString & defaultFolderIcon =
635  KGlobal::staticQString(KMimeType::mimeType( "inode/directory" )->KServiceType::icon());
636 
637  if ( S_ISDIR( m_fileMode ) )
638  return DesktopIcon( defaultFolderIcon, _size, _state );
639 
640  return DesktopIcon( "unknown", _size, _state );
641  }
642 
643  _state |= overlays();
644 
645  KMimeType::Ptr mime;
646  // Use guessed mimetype if the main one hasn't been determined for sure
647  if ( !m_bMimeTypeKnown && !m_guessedMimeType.isEmpty() )
648  mime = KMimeType::mimeType( m_guessedMimeType );
649  else
650  mime = m_pMimeType;
651 
652  // Support for gzipped files: extract mimetype of contained file
653  // See also the relevant code in overlays, which adds the zip overlay.
654  if ( mime->name() == "application/x-gzip" && m_url.fileName().right(3) == ".gz" )
655  {
656  KURL sf;
657  sf.setPath( m_url.path().left( m_url.path().length() - 3 ) );
658  //kdDebug() << "KFileItem::pixmap subFileName=" << subFileName << endl;
659  mime = KMimeType::findByURL( sf, 0, m_bIsLocalURL );
660  }
661 
662  bool isLocalURL;
663  KURL url = mostLocalURL(isLocalURL);
664 
665  TQPixmap p = mime->pixmap( url, KIcon::Desktop, _size, _state );
666  //kdDebug() << "finding pixmap for " << url.url() << " : " << mime->name() << endl;
667  if (p.isNull())
668  kdWarning() << "Pixmap not found for mimetype " << m_pMimeType->name() << endl;
669 
670  return p;
671 }
672 
673 bool KFileItem::isReadable() const
674 {
675  /*
676  struct passwd * user = getpwuid( geteuid() );
677  bool isMyFile = (TQString::fromLocal8Bit(user->pw_name) == m_user);
678  // This gets ugly for the group....
679  // Maybe we want a static TQString for the user and a static QStringList
680  // for the groups... then we need to handle the deletion properly...
681  */
682 
683  if ( m_permissions != KFileItem::Unknown ) {
684  // No read permission at all
685  if ( !(S_IRUSR & m_permissions) && !(S_IRGRP & m_permissions) && !(S_IROTH & m_permissions) )
686  return false;
687 
688  // Read permissions for all: save a stat call
689  if ( (S_IRUSR|S_IRGRP|S_IROTH) & m_permissions )
690  return true;
691  }
692 
693  // Or if we can't read it [using ::access()] - not network transparent
694  if ( m_bIsLocalURL && ::access( TQFile::encodeName(m_url.path()), R_OK ) == -1 )
695  return false;
696 
697  return true;
698 }
699 
700 bool KFileItem::isWritable() const
701 {
702  /*
703  struct passwd * user = getpwuid( geteuid() );
704  bool isMyFile = (TQString::fromLocal8Bit(user->pw_name) == m_user);
705  // This gets ugly for the group....
706  // Maybe we want a static TQString for the user and a static QStringList
707  // for the groups... then we need to handle the deletion properly...
708  */
709 
710  if ( m_permissions != KFileItem::Unknown ) {
711  // No write permission at all
712  if ( !(S_IWUSR & m_permissions) && !(S_IWGRP & m_permissions) && !(S_IWOTH & m_permissions) )
713  return false;
714  }
715 
716  // Or if we can't read it [using ::access()] - not network transparent
717  if ( m_bIsLocalURL && ::access( TQFile::encodeName(m_url.path()), W_OK ) == -1 )
718  return false;
719 
720  return true;
721 }
722 
723 bool KFileItem::isHidden() const
724 {
725  if ( m_hidden != Auto )
726  return m_hidden == Hidden;
727 
728  if ( !m_url.isEmpty() )
729  return m_url.fileName()[0] == '.';
730  else // should never happen
731  return m_strName[0] == '.';
732 }
733 
734 bool KFileItem::isDir() const
735 {
736  if ( m_fileMode == KFileItem::Unknown )
737  {
738  kdDebug() << " KFileItem::isDir can't say -> false " << endl;
739  return false; // can't say for sure, so no
740  }
741  return (S_ISDIR(m_fileMode));
742 /*
743  if (!S_ISDIR(m_fileMode)) {
744  if (m_url.isLocalFile()) {
745  KMimeType::Ptr ptr=KMimeType::findByURL(m_url,0,true,true);
746  if ((ptr!=0) && (ptr->is("directory/inode"))) return true;
747  }
748  return false
749  } else return true;*/
750 }
751 
752 bool KFileItem::acceptsDrops()
753 {
754  // A directory ?
755  if ( S_ISDIR( mode() ) ) {
756  return isWritable();
757  }
758 
759  // But only local .desktop files and executables
760  if ( !m_bIsLocalURL )
761  return false;
762 
763  if (( mimetype() == "application/x-desktop") ||
764  ( mimetype() == "media/builtin-mydocuments") ||
765  ( mimetype() == "media/builtin-mycomputer") ||
766  ( mimetype() == "media/builtin-mynetworkplaces") ||
767  ( mimetype() == "media/builtin-printers") ||
768  ( mimetype() == "media/builtin-trash") ||
769  ( mimetype() == "media/builtin-webbrowser"))
770  return true;
771 
772  // Executable, shell script ... ?
773  if ( ::access( TQFile::encodeName(m_url.path()), X_OK ) == 0 )
774  return true;
775 
776  return false;
777 }
778 
779 TQString KFileItem::getStatusBarInfo()
780 {
781  TQString text = m_strText;
782 
783  if ( m_bLink )
784  {
785  if ( !d ) {
786  d = new KFileItemPrivate();
787  }
788  if (!d->commentCached) {
789  d->comment = determineMimeType()->comment( m_url, m_bIsLocalURL );
790  d->commentCached = true;
791  }
792  TQString tmp;
793  if ( d->comment.isEmpty() )
794  tmp = i18n ( "Symbolic Link" );
795  else
796  tmp = i18n("%1 (Link)").arg(d->comment);
797  text += "->";
798  text += linkDest();
799  text += " ";
800  text += tmp;
801  }
802  else if ( S_ISREG( m_fileMode ) )
803  {
804  bool hasSize;
805  KIO::filesize_t sizeValue = size(hasSize);
806  if(hasSize)
807  text += TQString(" (%1) ").arg( KIO::convertSize( sizeValue ) );
808  text += mimeComment();
809  }
810  else if ( S_ISDIR ( m_fileMode ) )
811  {
812  text += "/ ";
813  text += mimeComment();
814  }
815  else
816  {
817  text += " ";
818  text += mimeComment();
819  }
820  text.replace('\n', " "); // replace any newlines with a space, so the statusbar doesn't get a two-line string which messes the display up, Alex
821  return text;
822 }
823 
824 TQString KFileItem::getToolTipText(int maxcount)
825 {
826  // we can return TQString::null if no tool tip should be shown
827  TQString tip;
828  KFileMetaInfo info = metaInfo();
829 
830  // the font tags are a workaround for the fact that the tool tip gets
831  // screwed if the color scheme uses white as default text color
832  const char* start = "<tr><td><nobr><font color=\"black\">";
833  const char* mid = "</font></nobr></td><td><nobr><font color=\"black\">";
834  const char* end = "</font></nobr></td></tr>";
835 
836  tip = "<table cellspacing=0 cellpadding=0>";
837 
838  tip += start + i18n("Name:") + mid + text() + end;
839  tip += start + i18n("Type:") + mid;
840 
841  TQString type = TQStyleSheet::escape(mimeComment());
842  if ( m_bLink ) {
843  tip += i18n("Link to %1 (%2)").arg(linkDest(), type) + end;
844  } else
845  tip += type + end;
846 
847  if ( !S_ISDIR ( m_fileMode ) ) {
848  bool hasSize;
849  KIO::filesize_t sizeValue = size(hasSize);
850  if(hasSize)
851  tip += start + i18n("Size:") + mid +
852  KIO::convertSizeWithBytes(sizeValue) + end;
853  }
854  TQString timeStr = timeString( KIO::UDS_MODIFICATION_TIME);
855  if(!timeStr.isEmpty())
856  tip += start + i18n("Modified:") + mid +
857  timeStr + end;
858 #ifndef Q_WS_WIN //TODO: show win32-specific permissions
859  TQString userStr = user();
860  TQString groupStr = group();
861  if(!userStr.isEmpty() || !groupStr.isEmpty())
862  tip += start + i18n("Owner:") + mid + userStr + " - " + groupStr + end +
863  start + i18n("Permissions:") + mid +
864  parsePermissions(m_permissions) + end;
865 #endif
866 
867  if (info.isValid() && !info.isEmpty() )
868  {
869  tip += "<tr><td colspan=2><center><s>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</s></center></td></tr>";
870  TQStringList keys = info.preferredKeys();
871 
872  // now the rest
873  TQStringList::Iterator it = keys.begin();
874  for (int count = 0; count<maxcount && it!=keys.end() ; ++it)
875  {
876  KFileMetaInfoItem item = info.item( *it );
877  if ( item.isValid() )
878  {
879  TQString s = item.string();
880  if ( ( item.attributes() & KFileMimeTypeInfo::SqueezeText )
881  && s.length() > 50) {
882  s.truncate(47);
883  s.append("...");
884  }
885  if ( !s.isEmpty() )
886  {
887  count++;
888  tip += start +
889  TQStyleSheet::escape( item.translatedKey() ) + ":" +
890  mid +
891  TQStyleSheet::escape( s ) +
892  end;
893  }
894 
895  }
896  }
897  }
898  tip += "</table>";
899 
900  //kdDebug() << "making this the tool tip rich text:\n";
901  //kdDebug() << tip << endl;
902 
903  return tip;
904 }
905 
906 void KFileItem::run()
907 {
908  // It might be faster to pass skip that when we know the mimetype,
909  // and just call KRun::runURL. But then we need to use mostLocalURL()
910  // for application/x-desktop files, to be able to execute them.
911  (void) new KRun( m_url, m_fileMode, m_bIsLocalURL );
912 }
913 
914 bool KFileItem::cmp( const KFileItem & item )
915 {
916  bool hasSize1,hasSize2,hasTime1,hasTime2;
917  hasSize1 = hasSize2 = hasTime1 = hasTime2 = false;
918  return ( m_strName == item.m_strName
919  && m_bIsLocalURL == item.m_bIsLocalURL
920  && m_fileMode == item.m_fileMode
921  && m_permissions == item.m_permissions
922  && m_user == item.m_user
923  && m_group == item.m_group
924  && m_bLink == item.m_bLink
925  && m_hidden == item.m_hidden
926  && size(hasSize1) == item.size(hasSize2)
927  && hasSize1 == hasSize2
928  && time(KIO::UDS_MODIFICATION_TIME, hasTime1) == item.time(KIO::UDS_MODIFICATION_TIME, hasTime2)
929  && hasTime1 == hasTime2
930  && (!d || !item.d || d->iconName == item.d->iconName) );
931 
932  // Don't compare the mimetypes here. They might not be known, and we don't want to
933  // do the slow operation of determining them here.
934 }
935 
936 void KFileItem::assign( const KFileItem & item )
937 {
938  if ( this == &item )
939  return;
940  m_entry = item.m_entry;
941  m_url = item.m_url;
942  m_bIsLocalURL = item.m_bIsLocalURL;
943  m_strName = item.m_strName;
944  m_strText = item.m_strText;
945  m_fileMode = item.m_fileMode;
946  m_permissions = item.m_permissions;
947  m_user = item.m_user;
948  m_group = item.m_group;
949  m_bLink = item.m_bLink;
950  m_pMimeType = item.m_pMimeType;
951  m_strLowerCaseName = item.m_strLowerCaseName;
952  m_bMimeTypeKnown = item.m_bMimeTypeKnown;
953  m_hidden = item.m_hidden;
954  m_guessedMimeType = item.m_guessedMimeType;
955  m_access = item.m_access;
956  m_metaInfo = item.m_metaInfo;
957  for ( int i = 0; i < NumFlags; i++ )
958  m_time[i] = item.m_time[i];
959  m_size = item.m_size;
960  // note: m_extra is NOT copied, as we'd have no control over who is
961  // deleting the data or not.
962 
963  // We had a mimetype previously (probably), so we need to re-determine it
964  determineMimeType();
965 
966  if ( item.d ) {
967  if ( !d ) {
968  d = new KFileItemPrivate;
969  }
970  d->iconName = item.d->iconName;
971  } else {
972  delete d;
973  d = 0;
974  }
975 }
976 
977 void KFileItem::setUDSEntry( const KIO::UDSEntry& _entry, const KURL& _url,
978  bool _determineMimeTypeOnDemand, bool _urlIsDirectory )
979 {
980  m_entry = _entry;
981  m_url = _url;
982  m_strName = TQString::null;
983  m_strText = TQString::null;
984  m_user = TQString::null;
985  m_group = TQString::null;
986  m_strLowerCaseName = TQString::null;
987  m_pMimeType = 0;
988  m_fileMode = KFileItem::Unknown;
989  m_permissions = KFileItem::Unknown;
990  m_bMarked = false;
991  m_bLink = false;
992  m_bIsLocalURL = _url.isLocalFile();
993  m_bMimeTypeKnown = false;
994  m_hidden = Auto;
995  m_guessedMimeType = TQString::null;
996  m_metaInfo = KFileMetaInfo();
997 
998  if ( d ) {
999  d->iconName = TQString::null;
1000  d->comment = TQString::null;
1001  d->commentCached = false;
1002  }
1003 
1004  readUDSEntry( _urlIsDirectory );
1005  init( _determineMimeTypeOnDemand );
1006 }
1007 
1008 void KFileItem::setFileMode( mode_t m )
1009 {
1010  m_fileMode = m;
1011 }
1012 
1013 void KFileItem::setMimeType( const TQString& mimetype )
1014 {
1015  m_pMimeType = KMimeType::mimeType( mimetype );
1016 }
1017 
1018 void KFileItem::setExtraData( const void *key, void *value )
1019 {
1020  if ( !key )
1021  return;
1022 
1023  m_extra.replace( key, value );
1024 }
1025 
1026 const void * KFileItem::extraData( const void *key ) const
1027 {
1028  TQMapConstIterator<const void*,void*> it = m_extra.find( key );
1029  if ( it != m_extra.end() )
1030  return it.data();
1031  return 0L;
1032 }
1033 
1034 void * KFileItem::extraData( const void *key )
1035 {
1036  TQMapIterator<const void*,void*> it = m_extra.find( key );
1037  if ( it != m_extra.end() )
1038  return it.data();
1039  return 0L;
1040 }
1041 
1042 void KFileItem::removeExtraData( const void *key )
1043 {
1044  m_extra.remove( key );
1045 }
1046 
1047 TQString KFileItem::permissionsString() const
1048 {
1049  if (m_access.isNull())
1050  m_access = parsePermissions( m_permissions );
1051 
1052  return m_access;
1053 }
1054 
1055 TQString KFileItem::parsePermissions(mode_t perm) const
1056 {
1057  char p[] = "---------- ";
1058 
1059  if (isDir())
1060  p[0]='d';
1061  else if (isLink())
1062  p[0]='l';
1063 
1064  if (perm & TQFileInfo::ReadUser)
1065  p[1]='r';
1066  if (perm & TQFileInfo::WriteUser)
1067  p[2]='w';
1068  if ((perm & TQFileInfo::ExeUser) && !(perm & S_ISUID)) p[3]='x';
1069  else if ((perm & TQFileInfo::ExeUser) && (perm & S_ISUID)) p[3]='s';
1070  else if (!(perm & TQFileInfo::ExeUser) && (perm & S_ISUID)) p[3]='S';
1071 
1072  if (perm & TQFileInfo::ReadGroup)
1073  p[4]='r';
1074  if (perm & TQFileInfo::WriteGroup)
1075  p[5]='w';
1076  if ((perm & TQFileInfo::ExeGroup) && !(perm & S_ISGID)) p[6]='x';
1077  else if ((perm & TQFileInfo::ExeGroup) && (perm & S_ISGID)) p[6]='s';
1078  else if (!(perm & TQFileInfo::ExeGroup) && (perm & S_ISGID)) p[6]='S';
1079 
1080  if (perm & TQFileInfo::ReadOther)
1081  p[7]='r';
1082  if (perm & TQFileInfo::WriteOther)
1083  p[8]='w';
1084  if ((perm & TQFileInfo::ExeOther) && !(perm & S_ISVTX)) p[9]='x';
1085  else if ((perm & TQFileInfo::ExeOther) && (perm & S_ISVTX)) p[9]='t';
1086  else if (!(perm & TQFileInfo::ExeOther) && (perm & S_ISVTX)) p[9]='T';
1087 
1088  if (hasExtendedACL())
1089  p[10]='+';
1090 
1091  return TQString::fromLatin1(p);
1092 }
1093 
1094 // check if we need to cache this
1095 TQString KFileItem::timeString( unsigned int which ) const
1096 {
1097  bool hasTime;
1098  time_t time_ = time(which, hasTime);
1099  if(!hasTime) return TQString::null;
1100 
1101  TQDateTime t;
1102  t.setTime_t( time_);
1103  return KGlobal::locale()->formatDateTime( t );
1104 }
1105 
1106 void KFileItem::setMetaInfo( const KFileMetaInfo & info )
1107 {
1108  m_metaInfo = info;
1109 }
1110 
1111 const KFileMetaInfo & KFileItem::metaInfo(bool autoget, int) const
1112 {
1113  bool isLocalURL;
1114  KURL url = mostLocalURL(isLocalURL);
1115 
1116  if ( autoget && !m_metaInfo.isValid() &&
1117  KGlobalSettings::showFilePreview(url) )
1118  {
1119  m_metaInfo = KFileMetaInfo( url, mimetype() );
1120  }
1121 
1122  return m_metaInfo;
1123 }
1124 
1125 KURL KFileItem::mostLocalURL(bool &local) const
1126 {
1127  TQString local_path = localPath();
1128 
1129  if ( !local_path.isEmpty() )
1130  {
1131  local = true;
1132  KURL url;
1133  url.setPath(local_path);
1134  return url;
1135  }
1136  else
1137  {
1138  local = m_bIsLocalURL;
1139  return m_url;
1140  }
1141 }
1142 
1143 void KFileItem::virtual_hook( int, void* )
1144 { /*BASE::virtual_hook( id, data );*/ }
1145 
1146 TQDataStream & operator<< ( TQDataStream & s, const KFileItem & a )
1147 {
1148  // We don't need to save/restore anything that refresh() invalidates,
1149  // since that means we can re-determine those by ourselves.
1150  s << a.m_url;
1151  s << a.m_strName;
1152  s << a.m_strText;
1153  return s;
1154 }
1155 
1156 TQDataStream & operator>> ( TQDataStream & s, KFileItem & a )
1157 {
1158  s >> a.m_url;
1159  s >> a.m_strName;
1160  s >> a.m_strText;
1161  a.m_bIsLocalURL = a.m_url.isLocalFile();
1162  a.m_bMimeTypeKnown = false;
1163  a.refresh();
1164  return s;
1165 }
KACL
The KCAL class encapsulates a POSIX Access Control List.
Definition: kacl.h:43
KFileItem
A KFileItem is a generic class to handle a file, local or remote.
Definition: kfileitem.h:42
KFileItem::text
const TQString & text() const
Returns the text of the file item.
Definition: kfileitem.h:289
KFileItem::mimeComment
TQString mimeComment()
Returns the descriptive comment for this mime type, or the mime type itself if none is present.
Definition: kfileitem.cpp:562
KFileItem::timeString
TQString timeString(unsigned int which=KIO::UDS_MODIFICATION_TIME) const
Requests the modification, access or creation time as a string, depending on which.
Definition: kfileitem.cpp:1095
KFileItem::operator=
KFileItem & operator=(const KFileItem &)
Assignment operator, calls assign()
Definition: kfileitem.cpp:121
KFileItem::permissionsString
TQString permissionsString() const
Returns the access permissions for the file as a string.
Definition: kfileitem.cpp:1047
KFileItem::linkDest
TQString linkDest() const
Returns the link destination if isLink() == true.
Definition: kfileitem.cpp:309
KFileItem::iconName
TQString iconName()
Returns the full path name to the icon that represents this mime type.
Definition: kfileitem.cpp:588
KFileItem::metaInfo
const KFileMetaInfo & metaInfo(bool autoget=true, int what=KFileMetaInfo::Fastest) const
Returns the metainfo of this item.
Definition: kfileitem.cpp:1111
KFileItem::setMimeType
void setMimeType(const TQString &mimetype)
Sets new mimetype for item.
Definition: kfileitem.cpp:1013
KFileItem::setName
void setName(const TQString &name)
Sets the item's name (i.e.
Definition: kfileitem.cpp:303
KFileItem::isWritable
bool isWritable() const
Checks whether the file or directory is writable.
Definition: kfileitem.cpp:700
KFileItem::time
time_t time(unsigned int which) const
Requests the modification, access or creation time, depending on which.
Definition: kfileitem.cpp:423
KFileItem::~KFileItem
virtual ~KFileItem()
Destructs the KFileItem.
Definition: kfileitem.cpp:127
KFileItem::mimetype
TQString mimetype() const
Returns the mimetype of the file item.
Definition: kfileitem.cpp:518
KFileItem::extraData
virtual const void * extraData(const void *key) const
Retrieves the extra data with the given key.
Definition: kfileitem.cpp:1026
KFileItem::user
TQString user() const
Returns the owner of the file.
Definition: kfileitem.cpp:482
KFileItem::setExtraData
virtual void setExtraData(const void *key, void *value)
This allows to associate some "extra" data to a KFileItem.
Definition: kfileitem.cpp:1018
KFileItem::name
const TQString & name(bool lowerCase=false) const
Return the name of the file item (without a path).
Definition: kfileitem.h:298
KFileItem::KFileItem
KFileItem(const KIO::UDSEntry &_entry, const KURL &_url, bool _determineMimeTypeOnDemand=false, bool _urlIsDirectory=false)
Creates an item representing a file, from a UDSEntry.
Definition: kfileitem.cpp:59
KFileItem::size
KIO::filesize_t size() const
Returns the size of the file, if known.
Definition: kfileitem.cpp:417
KFileItem::setUDSEntry
void setUDSEntry(const KIO::UDSEntry &entry, const KURL &url, bool determineMimeTypeOnDemand=false, bool urlIsDirectory=false)
Reinitialize KFileItem with a new UDSEntry.
Definition: kfileitem.cpp:977
KFileItem::setURL
void setURL(const KURL &url)
Sets the item's URL.
Definition: kfileitem.cpp:297
KFileItem::assign
void assign(const KFileItem &item)
Somewhat like an assignment operator, but more explicit.
Definition: kfileitem.cpp:936
KFileItem::isLink
bool isLink() const
Returns true if this item represents a link in the UNIX sense of a link.
Definition: kfileitem.h:186
KFileItem::mimeTypePtrFast
KMimeType::Ptr mimeTypePtrFast()
Returns the mimetype of the file item.
Definition: kfileitem.cpp:534
KFileItem::parsePermissions
TQString parsePermissions(mode_t perm) const
Parses the given permission set and provides it for access()
Definition: kfileitem.cpp:1055
KFileItem::getToolTipText
TQString getToolTipText(int maxcount=6)
Returns the string to be displayed in the tool tip when the mouse is over this item.
Definition: kfileitem.cpp:824
KFileItem::hasExtendedACL
bool hasExtendedACL() const
Tells if the file has extended access level information ( Posix ACL )
Definition: kfileitem.cpp:379
KFileItem::defaultACL
KACL defaultACL() const
Returns the default access control list for the directory.
Definition: kfileitem.cpp:405
KFileItem::run
void run()
Let's "KRun" this file ! (e.g.
Definition: kfileitem.cpp:906
KFileItem::url
const KURL & url() const
Returns the url of the file.
Definition: kfileitem.h:113
KFileItem::removeExtraData
virtual void removeExtraData(const void *key)
Removes the extra data associated with an item via key.
Definition: kfileitem.cpp:1042
KFileItem::isReadable
bool isReadable() const
Checks whether the file or directory is readable.
Definition: kfileitem.cpp:673
KFileItem::overlays
int overlays() const
Returns the overlays (bitfield of KIcon::*Overlay flags) that are used for this item's pixmap.
Definition: kfileitem.cpp:599
KFileItem::determineMimeType
KMimeType::Ptr determineMimeType()
Returns the mimetype of the file item.
Definition: kfileitem.cpp:539
KFileItem::mimetypeFast
TQString mimetypeFast() const
Returns the mimetype of the file item.
Definition: kfileitem.cpp:524
KFileItem::getStatusBarInfo
TQString getStatusBarInfo()
Returns the string to be displayed in the statusbar, e.g.
Definition: kfileitem.cpp:779
KFileItem::setMetaInfo
void setMetaInfo(const KFileMetaInfo &info)
Sets the metainfo of this item to info.
Definition: kfileitem.cpp:1106
KFileItem::localPath
TQString localPath() const
Returns the local path if isLocalFile() == true or the KIO item has a UDS_LOCAL_PATH atom.
Definition: kfileitem.cpp:332
KFileItem::setFileMode
void setFileMode(mode_t m)
Sets the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
Definition: kfileitem.cpp:1008
KFileItem::acceptsDrops
bool acceptsDrops()
Returns true if files can be dropped over this item.
Definition: kfileitem.cpp:752
KFileItem::ACL
KACL ACL() const
Returns the access control list for the file.
Definition: kfileitem.cpp:390
KFileItem::group
TQString group() const
Returns the group of the file.
Definition: kfileitem.cpp:497
KFileItem::cmp
bool cmp(const KFileItem &item)
Somewhat like a comparison operator, but more explicit.
Definition: kfileitem.cpp:914
KFileItem::refreshMimeType
void refreshMimeType()
Re-reads mimetype information.
Definition: kfileitem.cpp:286
KFileItem::pixmap
TQPixmap pixmap(int _size, int _state=0) const
Returns a pixmap representing the file.
Definition: kfileitem.cpp:627
KFileItem::isDir
bool isDir() const
Returns true if this item represents a directory.
Definition: kfileitem.cpp:734
KFileItem::mode
mode_t mode() const
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
Definition: kfileitem.h:167
KFileItem::init
void init(bool _determineMimeTypeOnDemand)
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called agai...
Definition: kfileitem.cpp:132
KFileItem::isHidden
bool isHidden() const
Checks whether the file is hidden.
Definition: kfileitem.cpp:723
KFileItem::readUDSEntry
void readUDSEntry(bool _urlIsDirectory)
Extracts the data from the UDSEntry member and updates the KFileItem accordingly.
Definition: kfileitem.cpp:194
KFileItem::mostLocalURL
KURL mostLocalURL(bool &local) const
Tries to give a local URL for this file item if possible.
Definition: kfileitem.cpp:1125
KFileItem::refresh
void refresh()
Throw away and re-read (for local files) all information about the file.
Definition: kfileitem.cpp:268
KFileMetaInfoItem
A meta information item about a file.
Definition: kfilemetainfo.h:497
KFileMetaInfoItem::translatedKey
TQString translatedKey() const
Returns a translation of the key for displaying to the user.
Definition: kfilemetainfo.cpp:170
KFileMetaInfoItem::isValid
bool isValid() const
Return true if the item is valid, i.e.
Definition: kfilemetainfo.cpp:232
KFileMetaInfoItem::attributes
uint attributes() const
Returns the attributes for this item.
Definition: kfilemetainfo.cpp:222
KFileMetaInfoItem::string
TQString string(bool mangle=true) const
Returns a string containing the value, if possible.
Definition: kfilemetainfo.cpp:187
KFileMetaInfo
Meta Information about a file.
Definition: kfilemetainfo.h:927
KFileMetaInfo::preferredKeys
TQStringList preferredKeys() const
Returns a list of all preferred keys.
Definition: kfilemetainfo.cpp:428
KFileMetaInfo::isValid
bool isValid() const
Returns true if the item is valid, i.e.
Definition: kfilemetainfo.cpp:517
KFileMetaInfo::item
KFileMetaInfoItem item(const TQString &key) const
Returns the KFileMetaInfoItem with the given key.
Definition: kfilemetainfo.cpp:614
KFileMetaInfo::isEmpty
bool isEmpty() const
Returns false if the object contains data, true if it's empty.
Definition: kfilemetainfo.cpp:523
KFileMimeTypeInfo::SqueezeText
@ SqueezeText
If the text for this item is very long, it should be squeezed to the size of the widget where it's di...
Definition: kfilemetainfo.h:79
KMimeType::findByURL
static Ptr findByURL(const KURL &_url, mode_t _mode=0, bool _is_local_file=false, bool _fast_mode=false)
Finds a KMimeType with the given _url.
Definition: kmimetype.cpp:165
KMimeType::mimeType
static Ptr mimeType(const TQString &_name)
Retrieve a pointer to the mime type _name or a pointer to the default mime type "application/octet-st...
Definition: kmimetype.cpp:141
KNFSShare::isDirectoryShared
bool isDirectoryShared(const TQString &path) const
Wether or not the given path is shared by NFS.
Definition: knfsshare.cpp:178
KNFSShare::instance
static KNFSShare * instance()
Returns the one and only instance of KNFSShare.
Definition: knfsshare.cpp:211
KRun
To open files with their associated applications in KDE, use KRun.
Definition: krun.h:59
KSambaShare::instance
static KSambaShare * instance()
Returns the one and only instance of KSambaShare.
Definition: ksambashare.cpp:231
KServiceType::icon
TQString icon() const
Returns the icon associated with this service type.
Definition: kservicetype.h:94
KIO
A namespace for KIO globals.
Definition: authinfo.h:29
KIO::UDSEntry
TQValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the information for a file or URL.
Definition: global.h:506
KIO::filesize_t
TQ_ULLONG filesize_t
64-bit file size
Definition: global.h:39
KIO::decodeFileName
KIO_EXPORT TQString decodeFileName(const TQString &str)
Decodes (from the filename to the text displayed) This translates %2[fF] into /, %% into %,...
Definition: global.cpp:191
KIO::convertSize
KIO_EXPORT TQString convertSize(KIO::filesize_t size)
Converts size from bytes to the string representation.
Definition: global.cpp:53
KIO::convertSizeWithBytes
KIO_EXPORT TQString convertSizeWithBytes(KIO::filesize_t size)
Converts size from bytes to a string representation with includes the size in bytes.
Definition: global.cpp:45
KIO::UDS_ACL_STRING
@ UDS_ACL_STRING
The access control list serialized into a single string.
Definition: global.h:346
KIO::UDS_URL
@ UDS_URL
An alternative URL (If different from the caption)
Definition: global.h:370
KIO::UDS_ACCESS_TIME
@ UDS_ACCESS_TIME
The last time the file was opened.
Definition: global.h:359
KIO::UDS_MODIFICATION_TIME
@ UDS_MODIFICATION_TIME
The last time the file was modified.
Definition: global.h:357
KIO::UDS_CREATION_TIME
@ UDS_CREATION_TIME
The time the file was created.
Definition: global.h:361
KIO::UDS_LINK_DEST
@ UDS_LINK_DEST
Name of the file where the link points to Allows to check for a symlink (don't use S_ISLNK !...
Definition: global.h:368
KIO::UDS_MIME_TYPE
@ UDS_MIME_TYPE
A mime type; prevents guessing.
Definition: global.h:372
KIO::UDS_GROUP
@ UDS_GROUP
Group ID of the file owner.
Definition: global.h:327
KIO::UDS_FILE_TYPE
@ UDS_FILE_TYPE
File type, part of the mode returned by stat (for a link, this returns the file type of the pointed i...
Definition: global.h:365
KIO::UDS_USER
@ UDS_USER
User ID of the file owner.
Definition: global.h:321
KIO::UDS_SIZE
@ UDS_SIZE
Size of the file.
Definition: global.h:318
KIO::UDS_HIDDEN
@ UDS_HIDDEN
Treat the file as a hidden file or as a normal file, regardless of (the absence of) a leading dot in ...
Definition: global.h:340
KIO::UDS_GUESSED_MIME_TYPE
@ UDS_GUESSED_MIME_TYPE
A mime type to be used for displaying only.
Definition: global.h:375
KIO::UDS_EXTENDED_ACL
@ UDS_EXTENDED_ACL
Indicates that the entry has extended ACL entries.
Definition: global.h:343
KIO::UDS_LOCAL_PATH
@ UDS_LOCAL_PATH
A local file path if the ioslave display files sitting on the local filesystem (but in another hierar...
Definition: global.h:337
KIO::UDS_NAME
@ UDS_NAME
Filename - as displayed in directory listings etc.
Definition: global.h:334
KIO::UDS_ACCESS
@ UDS_ACCESS
Access permissions (part of the mode returned by stat)
Definition: global.h:355
KIO::UDS_ICON_NAME
@ UDS_ICON_NAME
Name of the icon, that should be used for displaying.
Definition: global.h:325
KIO::UDS_DEFAULT_ACL_STRING
@ UDS_DEFAULT_ACL_STRING
The default access control list serialized into a single string.
Definition: global.h:350

kio/kio

Skip menu "kio/kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kio/kio

Skip menu "kio/kio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kio by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |