QDir.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                        Information about a directory                          *
00004 *                                                                               *
00005 *********************************************************************************
00006 *        Copyright (C) 2003 by Niall Douglas.   All Rights Reserved.            *
00007 *       NOTE THAT I DO NOT PERMIT ANY OF MY CODE TO BE PROMOTED TO THE GPL      *
00008 *********************************************************************************
00009 * This code is free software; you can redistribute it and/or modify it under    *
00010 * the terms of the GNU Library General Public License v2.1 as published by the  *
00011 * Free Software Foundation EXCEPT that clause 3 does not apply ie; you may not  *
00012 * "upgrade" this code to the GPL without my prior written permission.           *
00013 * Please consult the file "License_Addendum2.txt" accompanying this file.       *
00014 *                                                                               *
00015 * This code is distributed in the hope that it will be useful,                  *
00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                          *
00018 *********************************************************************************
00019 * $Id:                                                                          *
00020 ********************************************************************************/
00021 
00022 #ifndef QDIR_H
00023 #define QDIR_H
00024 
00025 #include "FXString.h"
00026 #include "qstringlist.h"
00027 #undef mkdir
00028 
00029 namespace FX {
00030 
00035 class QFileInfo;
00036 typedef QValueList<QFileInfo> QFileInfoList;
00037 
00075 struct FXDirPrivate;
00076 class FXAPIR QDir
00077 {
00078     FXDirPrivate *p;
00079 public:
00084     enum FilterSpec {
00085         Dirs      =0x001,   
00086         Files     =0x002,   
00087         //Drives    =0x004, //!< Include drives
00088         NoSymLinks=0x008,   
00089         All       =0x007,   
00090         TypeMask  =0x00f,
00091 
00092         Readable  =0x010,   
00093         Writeable =0x020,   
00094         Writable  =0x020,
00095         Executable=0x040,   
00096         RWEMask   =0x070,
00097 
00098         //Modified  =0x080,
00099         Hidden    =0x100,   
00100         //System    =0x200,
00101         AccessMask=0x3f0,
00102 
00103         DefaultFilter=0xffffffff
00104     };
00106     enum SortSpec
00107     {
00108         Name      =0x00,    
00109         Time      =0x01,    
00110         Size      =0x02,    
00111         Unsorted  =0x03,    
00112         SortByMask=0x03,
00113 
00114         DirsFirst =0x04,    
00115         Reversed  =0x08,    
00116         IgnoreCase=0x10,    
00117 
00118         DefaultSort=0xffffffff
00119     };
00121     QDir();
00124     QDir(const FXString &path, const FXString &regex=FXString::nullStr(), int sortBy=Name|IgnoreCase, int filter=All);
00125     QDir(const QDir &o);
00126     QDir &operator=(const QDir &o);
00127     QDir &operator=(const FXString &path);
00128     ~QDir();
00130     bool operator==(const QDir &o) const;
00132     bool operator!=(const QDir &o) const;
00133 
00135     void setPath(const FXString &path);
00137     const FXString &path() const;
00139     FXString absPath() const;
00141     FXString canonicalPath() const;
00143     FXString dirName() const;
00145     FXString filePath(const FXString &file, bool acceptAbs=true) const;
00147     FXString absFilePath(const FXString &file, bool acceptAbs=true) const;
00149     static FXString convertSeparators(const FXString &path);
00151     bool cd(const FXString &name, bool acceptAbs=true);
00153     bool cdUp();
00154 
00156     const FXString &nameFilter() const;
00158     void setNameFilter(const FXString &regex);
00160     FilterSpec filter() const;
00162     void setFilter(int filter);
00164     SortSpec sorting() const;
00166     void setSorting(int sorting);
00168     bool matchAllDirs() const;
00170     void setMatchAllDirs(bool matchAll);
00171 
00173     FXuint count() const;
00175     const FXString &operator[](int idx) const;
00177     QStringList entryList(const FXString &regex, int filter=DefaultFilter, int sorting=DefaultSort);
00179     QStringList entryList(int filter=DefaultFilter, int sorting=DefaultSort) { return entryList(FXString::nullStr(), filter, sorting); }
00183     const QFileInfoList *entryInfoList(const FXString &regex, int filter=DefaultFilter, int sorting=DefaultSort);
00185     const QFileInfoList *entryInfoList(int filter=DefaultFilter, int sorting=DefaultSort) { return entryInfoList(FXString::nullStr(), filter, sorting); }
00190     static QStringList drives();
00192     void refresh();
00193 
00195     bool mkdir(const FXString &leaf, bool acceptAbs=true);
00197     bool rmdir(const FXString &leaf, bool acceptAbs=true);
00199     bool remove(const FXString &leaf, bool acceptAbs=true);
00201     bool rename(const FXString &src, const FXString &dest, bool acceptAbs=true);
00203     bool exists(const FXString &leaf, bool acceptAbs=true);
00204 
00206     bool isReadable() const;
00208     bool exists() const;
00210     bool isRoot() const;
00212     bool isRelative() const;
00214     void convertToAbs();
00215 
00217     static FXString separator();
00219     static QDir current();
00221     static QDir home();
00223     static QDir root();
00225     static FXString currentDirPath();
00227     static FXString homeDirPath();
00229     static FXString rootDirPath();
00231     static bool match(const FXString &filter, const FXString &filename);
00233     static FXString cleanDirPath(const FXString &path);
00235     static bool isRelativePath(const FXString &path);
00241     static QStringList extractChanges(const QDir &A, const QDir &B);
00242 };
00243 
00244 } // namespace
00245 
00246 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:25 2009 for TnFOX by doxygen v1.4.7