Doomseeker
   
  • Doomseeker
  • Wadseeker
  • Download
  • Tracker
  • Git
  • Docs
  • Main Page
  • Classes
  • Files
  • File List
  • File Members

src/core/datapaths.h

00001 //------------------------------------------------------------------------------
00002 // datapaths.h
00003 //------------------------------------------------------------------------------
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., 51 Franklin Street, Fifth Floor, Boston, MA
00018 // 02110-1301, USA.
00019 //
00020 //------------------------------------------------------------------------------
00021 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
00022 //------------------------------------------------------------------------------
00023 #ifndef __DATAPATHS_H__
00024 #define __DATAPATHS_H__
00025 
00026 #include "global.h"
00027 #include <QDir>
00028 #include <QString>
00029 #include <QStringList>
00030 
00039 class MAIN_EXPORT DataPaths
00040 {
00041         public:
00042                 enum MachineType
00043                 {
00044                         x86,
00045                         x64,
00046                         Preferred
00047                 };
00048 
00049                 static const QString    PROGRAMS_APPDATA_DIR_NAME;
00050                 static const QString    PROGRAMS_APPDATASUPPORT_DIR_NAME;
00051                 static const QString    DEMOS_DIR_NAME;
00052                 static const QString    TRANSLATIONS_DIR_NAME;
00053                 static const QString UPDATE_PACKAGES_DIR_NAME;
00054                 static const QString UPDATE_PACKAGE_FILENAME_PREFIX;
00055 
00066                 static QString                  programFilesDirectory(MachineType machineType);
00067 
00079                 static QStringList staticDataSearchDirs(const QString& subdir = QString());
00080 
00081                 DataPaths(bool bPortableModeOn = false);
00082 
00088                 QStringList                             canWrite() const;
00089 
00101                 bool                                    createDirectories();
00102 
00103                 QString                                 demosDirectoryPath() const;
00104 
00110                 QStringList                             directoriesExist() const;
00111 
00112                 const QString&                  directoryNameForProgram() const { return programsDirectoryName; }
00113 
00127                 QString localDataLocationPath(const QString& subpath = QString()) const;
00128 
00138                 QString                                 programsDataDirectoryPath() const;
00139 
00145                 QString                                 programsDataSupportDirectoryPath() const;
00146 
00147                 bool                                    isPortableModeOn() const { return bIsPortableModeOn; }
00148 
00149                 void                                    setPortableModeOn(bool b) { bIsPortableModeOn = b; }
00150                 void                                    setDirectoryNameForProgram(const QString& name) { programsDirectoryName = name; }
00151 
00168                 QString                                 systemAppDataDirectory(QString append = QString()) const;
00169 
00174                 bool                                    validateAppDataDirectory();
00175 
00176         protected:
00181                 static bool                             validateDir(const QString& path);
00182 
00183                 bool                                    bIsPortableModeOn;
00184 
00188                 QString                                 programsDirectoryName;
00189                 QString                                 programsSupportDirectoryName;
00190                 QString                                 demosDirectoryName;
00191 
00195                 bool                                    tryCreateDirectory(const QDir& rootDir, const QString& dirToCreate) const;
00196 };
00197 
00198 #endif
   
Doomseeker © 2009-2024 The Doomseeker Team