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 
00088     static QSet<QString> listContents(const QString& path, const Flags& flags=(Flags)0, bool recursive=false);
00089 
00092     static const QStringList& getSearchPaths(void) {return fileLocations;}
00093 
00096     static void setSearchPaths(const QStringList& paths);
00097 
00100     static void makeSureDirExistsAndIsWritable(const QString& dirFullPath);
00101 
00104     static bool exists(const QString& path);
00105 
00108     static bool isAbsolute(const QString& path);
00109 
00113     static bool isReadable(const QString& path);
00114 
00122     static bool isWritable(const QString& path);
00123 
00126     static bool isDirectory(const QString& path);
00127 
00130     static qint64 size(const QString& path);
00131 
00135     static bool mkDir(const QString& path);
00136 
00140     static QString dirName(const QString& path);
00141 
00145     static QString baseName(const QString& path);
00146 
00156     static QString getDesktopDir();
00157 
00165     static QString getUserDir();
00166 
00172     static QString getInstallationDir();
00173 
00175     static QString getCacheDir();
00176 
00180     static void setUserDir(const QString& newDir);
00181 
00187     static QString getScreenshotDir();
00188 
00194     static void setScreenshotDir(const QString& newDir);
00195 
00198     static QString getLocaleDir();
00199 
00200 private:
00201 
00203     StelFileMgr() {;}
00204 
00210     static bool fileFlagsCheck(const QString& path, const Flags& flags=(Flags)0);
00211 
00212     static QStringList fileLocations;
00213 
00215     static QString userDir;
00216 
00218     static QString screenshotDir;
00219 
00220 #ifdef Q_OS_WIN
00223     static QString getWin32SpecialDirPath(int csidlId);
00224 #endif
00225 
00226 };
00227 
00228 #endif // _STELFILEMGR_HPP_

Generated on Wed Jun 2 13:11:13 2010 for Stellarium by  doxygen 1.5.5