00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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_