Stellarium 0.11.0
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · 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     static void init();
00060 
00079     static QString findFile(const QString& path, const Flags& flags=(Flags)0);
00080 
00086     static QStringList findFileInAllPaths(const QString& path, const Flags& flags=(Flags)0);
00087 
00095     static QSet<QString> listContents(const QString& path, const Flags& flags=(Flags)0, bool recursive=false);
00096 
00099     static const QStringList& getSearchPaths(void) {return fileLocations;}
00100 
00103     static void setSearchPaths(const QStringList& paths);
00104 
00107     static void makeSureDirExistsAndIsWritable(const QString& dirFullPath);
00108 
00111     static bool exists(const QString& path);
00112 
00115     static bool isAbsolute(const QString& path);
00116 
00120     static bool isReadable(const QString& path);
00121 
00129     static bool isWritable(const QString& path);
00130 
00133     static bool isDirectory(const QString& path);
00134 
00137     static qint64 size(const QString& path);
00138 
00142     static bool mkDir(const QString& path);
00143 
00147     static QString dirName(const QString& path);
00148 
00152     static QString baseName(const QString& path);
00153 
00163     static QString getDesktopDir();
00164 
00172     static QString getUserDir();
00173 
00179     static QString getInstallationDir();
00180 
00182     static QString getCacheDir();
00183 
00187     static void setUserDir(const QString& newDir);
00188 
00194     static QString getScreenshotDir();
00195 
00201     static void setScreenshotDir(const QString& newDir);
00202 
00205     static QString getLocaleDir();
00206 
00207 private:
00208 
00210     StelFileMgr() {;}
00211 
00217     static bool fileFlagsCheck(const QString& path, const Flags& flags=(Flags)0);
00218 
00219     static QStringList fileLocations;
00220 
00222     static QString userDir;
00223 
00225     static QString screenshotDir;
00226 
00227 #ifdef Q_OS_WIN
00228 
00229 
00230     static QString getWin32SpecialDirPath(int csidlId);
00231 #endif
00232 
00233 };
00234 
00235 #endif // _STELFILEMGR_HPP_