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                 
00063                 static QString                  programFilesDirectory(MachineType machineType);         
00064         
00065                 DataPaths(bool bPortableModeOn = false);
00066 
00072                 QStringList                             canWrite() const;
00073                 
00085                 bool                                    createDirectories();
00086 
00087                 QString                                 demosDirectoryPath() const;
00088 
00094                 QStringList                             directoriesExist() const;
00095                 
00096                 const QString&                  directoryNameForProgram() const { return programsDirectoryName; }
00097                 
00107                 QString                                 programsDataDirectoryPath() const;
00108 
00114                 QString                                 programsDataSupportDirectoryPath() const;
00115                 
00116                 bool                                    isPortableModeOn() const { return bIsPortableModeOn; }
00117                 
00118                 void                                    setPortableModeOn(bool b) { bIsPortableModeOn = b; }
00119                 void                                    setDirectoryNameForProgram(const QString& name) { programsDirectoryName = name; }
00120                 
00137                 QString                                 systemAppDataDirectory(QString append = QString()) const;               
00138 
00143                 bool                                    validateAppDataDirectory();
00144                                 
00145         protected:
00150                 static bool                             validateDir(const QString& path);       
00151         
00152                 bool                                    bIsPortableModeOn;
00153                 
00157                 QString                                 programsDirectoryName;
00158                 QString                                 programsSupportDirectoryName;
00159                 QString                                 demosDirectoryName;
00160                 
00164                 bool                                    tryCreateDirectory(const QDir& rootDir, const QString& dirToCreate) const;
00165 };
00166 
00167 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator