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

tdeio/tdeio

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

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.1
This website is maintained by Timothy Pearson.