Home · All Namespaces · All Classes · Functions · Coding Style · Plugins · File Structure

core/StelFileMgr.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2008 Stellarium Developers
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef _STELFILEMGR_HPP
00021 #define _STELFILEMGR_HPP_
00022 
00023 #define CHECK_FILE "data/ssystem.ini"
00024 
00025 #include <stdexcept>
00026 #include <QSet>
00027 #include <QString>
00028 #include <QStringList>
00029 
00040 class StelFileMgr
00041 {
00042 public:
00044     enum Flags {
00045         RemovableMedia = 0x00000001,  
00046         Writable       = 0x00000002,  
00047 
00048         Directory      = 0x00000004, 
00049         File           = 0x00000008, 
00050         New            = 0x00000010, 
00051         Hidden         = 0x00000020  
00052     };
00053                 
00059     StelFileMgr();
00060     
00062     ~StelFileMgr();
00063 
00082     QString findFile(const QString& path, const Flags& flags=(Flags)0);
00083     
00091     QSet<QString> listContents(const QString& path, const Flags& flags=(Flags)0, bool recursive=false);
00092         
00095     const QStringList& getSearchPaths(void) { return fileLocations; }
00096     
00099     void setSearchPaths(const QStringList& paths);
00100         
00103     static bool exists(const QString& path);
00104     
00112     static bool isWritable(const QString& path);
00113     
00116     static bool isDirectory(const QString& path);
00117     
00120     static qint64 size(const QString& path);
00121     
00125     static bool mkDir(const QString& path);
00126     
00130     QString dirName(const QString& path);
00131     
00141     QString getDesktopDir(void);
00142     
00150     QString getUserDir(void);
00151 
00155     void setUserDir(const QString& newDir);
00156     
00163     QString getScreenshotDir(void);
00164 
00170     void setScreenshotDir(const QString& newDir);
00171         
00174     QString getLocaleDir(void);
00175 
00176 private:
00180     void checkUserDir();
00181     
00185     QString baseName(const QString& path);
00186     
00192     QString getInstallationDir(void);
00193     
00199     bool fileFlagsCheck(const QString& path, const Flags& flags=(Flags)0);
00200     
00201     QStringList fileLocations;
00202 
00204     QString userDir;
00205 
00207     QString screenshotDir;
00208 
00209 #if defined(WIN32)
00212     static QString getWin32SpecialDirPath(const int csidlId);
00213 #endif
00214 
00215 };
00216 
00217 #endif // _STELFILEMGR_HPP_

Generated on Mon Mar 9 16:16:15 2009 for Stellarium by  doxygen 1.5.5