home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qdir.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  7KB  |  242 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qdir.h   3.0.0   edited Jun 22 12:41 $
  3. **
  4. ** Definition of QDir class
  5. **
  6. ** Created : 950427
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the tools module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QDIR_H
  39. #define QDIR_H
  40.  
  41. #ifndef QT_H
  42. #include "qstrlist.h"
  43. #include "qfileinfo.h"
  44. #include "qglobal.h"
  45. #include "qwindowdefs.h"
  46. #endif // QT_H
  47.  
  48.  
  49. #ifndef QT_NO_DIR
  50. typedef QPtrList<QFileInfo> QFileInfoList;
  51. typedef QPtrListIterator<QFileInfo> QFileInfoListIterator;
  52. class QStringList;
  53.  
  54.  
  55. class Q_EXPORT QDir
  56. {
  57. public:
  58.     enum FilterSpec { Dirs        = 0x001,
  59.               Files        = 0x002,
  60.               Drives        = 0x004,
  61.               NoSymLinks    = 0x008,
  62.               All        = 0x007,
  63.                TypeMask        = 0x00F,
  64.  
  65.               Readable        = 0x010,
  66.               Writable        = 0x020,
  67.               Executable    = 0x040,
  68.                RWEMask        = 0x070,
  69.  
  70.               Modified        = 0x080,
  71.               Hidden        = 0x100,
  72.               System        = 0x200,
  73.                AccessMask    = 0x3F0,
  74.  
  75.               DefaultFilter = -1 };
  76.  
  77.     enum SortSpec   { Name        = 0x00,
  78.               Time        = 0x01,
  79.               Size        = 0x02,
  80.               Unsorted        = 0x03,
  81.                SortByMask    = 0x03,
  82.  
  83.               DirsFirst        = 0x04,
  84.               Reversed        = 0x08,
  85.               IgnoreCase    = 0x10,
  86.               DefaultSort   = -1 };
  87.  
  88.     QDir();
  89.     QDir( const QString &path, const QString &nameFilter = QString::null,
  90.       int sortSpec = Name | IgnoreCase, int filterSpec = All );
  91.     QDir( const QDir & );
  92.  
  93.     virtual ~QDir();
  94.  
  95.     QDir       &operator=( const QDir & );
  96.     QDir       &operator=( const QString &path );
  97.  
  98.     virtual void setPath( const QString &path );
  99.     virtual QString path()        const;
  100.     virtual QString absPath()    const;
  101.     virtual QString canonicalPath()    const;
  102.  
  103.     virtual QString dirName() const;
  104.     virtual QString filePath( const QString &fileName,
  105.                   bool acceptAbsPath = TRUE ) const;
  106.     virtual QString absFilePath( const QString &fileName,
  107.                  bool acceptAbsPath = TRUE ) const;
  108.  
  109.     static QString convertSeparators( const QString &pathName );
  110.  
  111.     virtual bool cd( const QString &dirName, bool acceptAbsPath = TRUE );
  112.     virtual bool cdUp();
  113.  
  114.     QString    nameFilter() const;
  115.     virtual void setNameFilter( const QString &nameFilter );
  116.     FilterSpec filter() const;
  117.     virtual void setFilter( int filterSpec );
  118.     SortSpec sorting() const;
  119.     virtual void setSorting( int sortSpec );
  120.  
  121.     bool    matchAllDirs() const;
  122.     virtual void setMatchAllDirs( bool );
  123.  
  124.     uint count() const;
  125.     QString    operator[]( int ) const;
  126.  
  127.     virtual QStrList encodedEntryList( int filterSpec = DefaultFilter,
  128.                        int sortSpec   = DefaultSort  ) const;
  129.     virtual QStrList encodedEntryList( const QString &nameFilter,
  130.                        int filterSpec = DefaultFilter,
  131.                        int sortSpec   = DefaultSort   ) const;
  132.     virtual QStringList entryList( int filterSpec = DefaultFilter,
  133.                    int sortSpec   = DefaultSort  ) const;
  134.     virtual QStringList entryList( const QString &nameFilter,
  135.                    int filterSpec = DefaultFilter,
  136.                    int sortSpec   = DefaultSort   ) const;
  137.  
  138.     virtual const QFileInfoList *entryInfoList( int filterSpec = DefaultFilter,
  139.                         int sortSpec = DefaultSort ) const;
  140.     virtual const QFileInfoList *entryInfoList( const QString &nameFilter,
  141.                         int filterSpec = DefaultFilter,
  142.                         int sortSpec = DefaultSort ) const;
  143.  
  144.     static const QFileInfoList *drives();
  145.  
  146.     virtual bool mkdir( const QString &dirName,
  147.             bool acceptAbsPath = TRUE ) const;
  148.     virtual bool rmdir( const QString &dirName,
  149.             bool acceptAbsPath = TRUE ) const;
  150.  
  151.     virtual bool isReadable() const;
  152.     virtual bool exists()   const;
  153.     virtual bool isRoot()   const;
  154.  
  155.     virtual bool isRelative() const;
  156.     virtual void convertToAbs();
  157.  
  158.     virtual bool operator==( const QDir & ) const;
  159.     virtual bool operator!=( const QDir & ) const;
  160.  
  161.     virtual bool remove( const QString &fileName,
  162.              bool acceptAbsPath = TRUE );
  163.     virtual bool rename( const QString &name, const QString &newName,
  164.              bool acceptAbsPaths = TRUE  );
  165.     virtual bool exists( const QString &name,
  166.              bool acceptAbsPath = TRUE );
  167.  
  168.     static char separator();
  169.  
  170.     static bool setCurrent( const QString &path );
  171.     static QDir current();
  172.     static QDir home();
  173.     static QDir root();
  174.     static QString currentDirPath();
  175.     static QString homeDirPath();
  176.     static QString rootDirPath();
  177.  
  178.     static bool match( const QStringList &filters, const QString &fileName );
  179.     static bool match( const QString &filter, const QString &fileName );
  180.     static QString cleanDirPath( const QString &dirPath );
  181.     static bool isRelativePath( const QString &path );
  182.  
  183. private:
  184. #ifdef Q_OS_MAC
  185.     static FSSpec *make_spec(const QString &);
  186. #endif
  187.     void init();
  188.     virtual bool readDirEntries( const QString &nameFilter,
  189.                  int FilterSpec, int SortSpec  );
  190.  
  191.     static void slashify ( QString &);
  192.  
  193.     QString    dPath;
  194.     QStringList   *fList;
  195.     QFileInfoList *fiList;
  196.     QString    nameFilt;
  197.     FilterSpec    filtS;
  198.     SortSpec    sortS;
  199.     uint    dirty    : 1;
  200.     uint    allDirs : 1;
  201. };
  202.  
  203.  
  204. inline QString QDir::path() const
  205. {
  206.     return dPath;
  207. }
  208.  
  209. inline QString QDir::nameFilter() const
  210. {
  211.     return nameFilt;
  212. }
  213.  
  214. inline QDir::FilterSpec QDir::filter() const
  215. {
  216.     return filtS;
  217. }
  218.  
  219. inline QDir::SortSpec QDir::sorting() const
  220. {
  221.     return sortS;
  222. }
  223.  
  224. inline bool QDir::matchAllDirs() const
  225. {
  226.     return allDirs;
  227. }
  228.  
  229. inline bool QDir::operator!=( const QDir &d ) const
  230. {
  231.     return !(*this == d);
  232. }
  233.  
  234.  
  235. struct QDirSortItem {
  236.     QString filename_cache;
  237.     QFileInfo* item;
  238. };
  239.  
  240. #endif // QT_NO_DIR
  241. #endif // QDIR_H
  242.