From 0144305c6a50e88158c09c76a56126ae8f5f3449 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 25 Oct 2015 22:10:54 +1100 Subject: [PATCH] [Project64] Clean up path code --- Source/Common/Trace.h | 61 ++-- Source/Common/TraceDefs.h | 47 ++- Source/Common/path.cpp | 323 ++++++++--------- Source/Common/path.h | 172 ++++----- Source/Common/stdafx.h | 1 - Source/GlideHQ/TxCache.cpp | 3 +- Source/GlideHQ/TxFilter.cpp | 7 +- Source/GlideHQ/TxHiResCache.cpp | 8 +- Source/GlideHQ/TxTexCache.cpp | 5 +- Source/Project64/N64 System/Mips/Eeprom.cpp | 2 +- Source/Project64/N64 System/Mips/FlashRam.cpp | 2 +- Source/Project64/N64 System/Mips/Mempak.cpp | 2 +- Source/Project64/N64 System/Mips/Sram.cpp | 2 +- Source/Project64/Plugins/Plugin Class.cpp | 8 +- Source/Project64/Plugins/Plugin List.h | 19 +- .../SettingType/SettingsType-Application.cpp | 2 +- .../SettingsType-ApplicationPath.cpp | 5 +- .../SettingsType-ApplicationPath.h | 25 +- .../SettingType/SettingsType-RDBOnOff.cpp | 93 +++-- .../SettingType/SettingsType-RDBOnOff.h | 45 +-- .../SettingType/SettingsType-RDBYesNo.cpp | 105 +++--- .../SettingType/SettingsType-RDBYesNo.h | 45 +-- .../SettingsType-RomDatabaseSetting.cpp | 8 +- .../SettingsType-RomDatabaseSetting.h | 26 +- .../SettingType/SettingsType-RomSetting.h | 59 +-- Source/Project64/main.cpp | 339 +++++++++--------- 26 files changed, 706 insertions(+), 708 deletions(-) diff --git a/Source/Common/Trace.h b/Source/Common/Trace.h index 4c8d21fd3..3bda9afb4 100644 --- a/Source/Common/Trace.h +++ b/Source/Common/Trace.h @@ -1,50 +1,47 @@ -#ifndef __TRACE_H__ -#define __TRACE_H__ +#pragma once -class CTraceModule +class CTraceModule { - TraceLevel m_Type; - -public: - CTraceModule () { m_Type = TrLvError; } - virtual ~CTraceModule () {} + TraceLevel m_Type; - inline void SetTraceLevel ( TraceLevel Type ) { m_Type = Type; } - inline TraceLevel GetTraceLevel ( void ) const { return m_Type; } - virtual void Write ( LPCTSTR Message, bool EndOfLine ) = 0; +public: + CTraceModule () { m_Type = TrLvError; } + virtual ~CTraceModule () {} + + inline void SetTraceLevel ( TraceLevel Type ) { m_Type = Type; } + inline TraceLevel GetTraceLevel ( void ) const { return m_Type; } + virtual void Write ( LPCTSTR Message, bool EndOfLine ) = 0; }; class CTraceFileLog : public CTraceModule { - enum { MB = 1024 * 1024 }; + enum { MB = 1024 * 1024 }; - CriticalSection m_CriticalSection; - CLog m_hLogFile; - bool m_FlushFile; + CriticalSection m_CriticalSection; + CLog m_hLogFile; + bool m_FlushFile; public: - CTraceFileLog (LPCTSTR FileName, bool FlushFile = true); - CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize = 5); - virtual ~CTraceFileLog (); - - void Write ( LPCTSTR Message, bool EndOfLine ); - void SetFlushFile ( bool bFlushFile ); + CTraceFileLog (LPCTSTR FileName, bool FlushFile = true); + CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize = 5); + virtual ~CTraceFileLog (); + + void Write ( LPCTSTR Message, bool EndOfLine ); + void SetFlushFile ( bool bFlushFile ); }; class CDebugTraceLog : public CTraceModule { -public: - void Write ( LPCTSTR Message, bool EndOfLine ) - { - OutputDebugString(Message); - if (EndOfLine) - { - OutputDebugString("\n"); - } - } +public: + void Write ( LPCTSTR Message, bool EndOfLine ) + { + OutputDebugString(Message); + if (EndOfLine) + { + OutputDebugString("\n"); + } + } }; CTraceModule * AddTraceModule ( CTraceModule * TraceModule ); // Must be created with new CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule ); // Is not automaticly deleted - -#endif // __TRACE_H__ diff --git a/Source/Common/TraceDefs.h b/Source/Common/TraceDefs.h index 79a317fa8..65fae3295 100644 --- a/Source/Common/TraceDefs.h +++ b/Source/Common/TraceDefs.h @@ -1,36 +1,31 @@ -#ifndef __TRACE_DEFS_H__ -#define __TRACE_DEFS_H__ +#pragma once enum TraceType { - TraceNone = 0x00000000, - TraceError = 0x00000001, - TraceSettings = 0x00000002, - TraceGfxPlugin = 0x00000004, - TraceDebug = 0x00000010, - TraceRecompiler = 0x00000020, - TraceRSP = 0x00000040, - TraceTLB = 0x00000080, - TraceValidate = 0x00000100, - TraceAudio = 0x00000200, - TraceProtectedMem = 0x00000400, - TraceNoHeader = 0x80000000, + TraceNone = 0x00000000, + TraceError = 0x00000001, + TraceSettings = 0x00000002, + TraceGfxPlugin = 0x00000004, + TraceDebug = 0x00000010, + TraceRecompiler = 0x00000020, + TraceRSP = 0x00000040, + TraceTLB = 0x00000080, + TraceValidate = 0x00000100, + TraceAudio = 0x00000200, + TraceProtectedMem = 0x00000400, + TraceNoHeader = 0x80000000, }; enum TraceLevel { - //Handle Existing Code - TrLvError = TraceError, - TrLv1 = TraceSettings | TrLvError, - TrLv2 = TrLv1 | TraceDebug, - TrlvGfxPlugin = TraceGfxPlugin, - TrLvAll = ~TraceNoHeader, + //Handle Existing Code + TrLvError = TraceError, + TrLv1 = TraceSettings | TrLvError, + TrLv2 = TrLv1 | TraceDebug, + TrlvGfxPlugin = TraceGfxPlugin, + TrLvAll = ~TraceNoHeader, }; - -void WriteTrace ( TraceType Type, LPCTSTR Message ); -void WriteTraceF ( TraceType Type, LPCTSTR strFormat, ... ); +void WriteTrace ( TraceType Type, const char * Message ); +void WriteTraceF ( TraceType Type, const char * strFormat, ... ); void CloseTrace ( void ); //Free's all memory associated with trace - - -#endif // __TRACE_DEFS_H__ diff --git a/Source/Common/path.cpp b/Source/Common/path.cpp index 94e1c41d1..d21893411 100644 --- a/Source/Common/path.cpp +++ b/Source/Common/path.cpp @@ -3,36 +3,36 @@ ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include -#include +#include ////////////////////////////////////////////////////////////////////// // Constants ////////////////////////////////////////////////////////////////////// -LPCTSTR const DLL_EXTENSION = _T("dll"); -LPCTSTR const INI_EXTENSION = _T("ini"); -LPCTSTR const EXE_EXTENSION = _T("exe"); -LPCTSTR const WILD_NAME_EXTENSION = _T("*.*"); +const char * const DLL_EXTENSION = "dll"; +const char * const INI_EXTENSION = "ini"; +const char * const EXE_EXTENSION = "exe"; +const char * const WILD_NAME_EXTENSION = "*.*"; const TCHAR WILD_ONE = '?'; const TCHAR WILD_ANY = '*'; -LPCTSTR const WILD_SET = _T("?*"); -LPCTSTR const DIR_DOUBLEDELIM = _T("\\\\"); +const char * const WILD_SET = "?*"; +const char * const DIR_DOUBLEDELIM = "\\\\"; const TCHAR DRIVE_DELIMITER = ':'; const TCHAR DIRECTORY_DELIMITER = '\\'; const TCHAR EXTENSION_DELIMITER = '.'; const TCHAR DIRECTORY_DELIMITER2 = '/'; -HINSTANCE CPath::m_hInst = NULL; +void * CPath::m_hInst = NULL; ////////////////////////////////////////////////////////////////////// // Helpers ////////////////////////////////////////////////////////////////////// -void CPath::SethInst ( HINSTANCE hInst ) +void CPath::SethInst ( void * hInst ) { m_hInst = hInst; } -HINSTANCE CPath::GethInst() +void * CPath::GethInst() { return m_hInst; } @@ -90,14 +90,14 @@ CPath::CPath(const CPath& rPath) //------------------------------------------------------------- // Task : Constructs a path and points it 2 lpszPath //------------------------------------------------------------- -CPath::CPath(LPCTSTR lpszPath) +CPath::CPath(const char * lpszPath) { Init(); - m_strPath =lpszPath ? lpszPath : _T(""); + m_strPath =lpszPath ? lpszPath : ""; cleanPathString(m_strPath); } -CPath::CPath(LPCTSTR lpszPath, LPCTSTR NameExten) +CPath::CPath(const char * lpszPath, const char * NameExten) { Init(); SetDriveDirectory(lpszPath); @@ -107,7 +107,7 @@ CPath::CPath(LPCTSTR lpszPath, LPCTSTR NameExten) //------------------------------------------------------------- // Task : Constructs a path and points it 2 strPath //------------------------------------------------------------- -CPath::CPath(const stdstr& strPath) +CPath::CPath(const std::string& strPath) { Init(); m_strPath =strPath; @@ -117,7 +117,7 @@ CPath::CPath(const stdstr& strPath) //------------------------------------------------------------- // Task : Constructs a path and points it 2 strPath //------------------------------------------------------------- -CPath::CPath(const stdstr& strPath, LPCTSTR NameExten ) +CPath::CPath(const std::string& strPath, const char * NameExten) { Init(); SetDriveDirectory(strPath.c_str()); @@ -127,7 +127,7 @@ CPath::CPath(const stdstr& strPath, LPCTSTR NameExten ) //------------------------------------------------------------- // Task : Constructs a path and points it 2 strPath //------------------------------------------------------------- -CPath::CPath(const stdstr& strPath, const stdstr& NameExten ) +CPath::CPath(const std::string& strPath, const std::string& NameExten) { Init(); SetDriveDirectory(strPath.c_str()); @@ -147,24 +147,24 @@ CPath::~CPath() // Post : Return TRUE if paths are equal // Task : Check if the two path are the same //------------------------------------------------------------- -BOOL CPath::operator ==(const CPath& rPath) const +bool CPath::operator ==(const CPath& rPath) const { // Get fully qualified versions of the paths - stdstr FullyQualified1; - stdstr FullyQualified2; + std::string FullyQualified1; + std::string FullyQualified2; GetFullyQualified(FullyQualified1); rPath.GetFullyQualified(FullyQualified2); // Compare them - return _tcsicmp(FullyQualified1.c_str(),FullyQualified2.c_str()) == 0; + return _stricmp(FullyQualified1.c_str(), FullyQualified2.c_str()) == 0; } //------------------------------------------------------------- // Post : Return TRUE if paths are different // Task : Check if the two path are different //------------------------------------------------------------- -BOOL CPath::operator !=(const CPath& rPath) const +bool CPath::operator !=(const CPath& rPath) const { return !(*this == rPath); } @@ -183,9 +183,9 @@ CPath& CPath::operator =(const CPath& rPath) // Post : Return the path, so that assignements can be chained // Task : Assign a string 2 a path //------------------------------------------------------------- -CPath& CPath::operator =(LPCTSTR lpszPath) +CPath& CPath::operator =(const char * lpszPath) { - m_strPath =lpszPath ? lpszPath : _T(""); + m_strPath =lpszPath ? lpszPath : ""; return *this; } @@ -193,7 +193,7 @@ CPath& CPath::operator =(LPCTSTR lpszPath) // Post : Return the path, so that assignements can be chained // Task : Assign a string 2 a path //------------------------------------------------------------- -CPath& CPath::operator =(const stdstr& strPath) +CPath& CPath::operator =(const std::string& strPath) { m_strPath =strPath; return *this; @@ -207,12 +207,12 @@ CPath& CPath::operator =(const stdstr& strPath) // function in any non-constant pointer and alter the data. // Very dangerous //------------------------------------------------------------- -CPath::operator LPCTSTR() const +CPath::operator const char *() const { - return (LPCTSTR)m_strPath.c_str(); + return (const char *)m_strPath.c_str(); } -CPath::CPath(DIR_CURRENT_DIRECTORY /*sdt*/, LPCTSTR NameExten) +CPath::CPath(DIR_CURRENT_DIRECTORY /*sdt*/, const char * NameExten) { // Application's current directory Init(); @@ -220,7 +220,7 @@ CPath::CPath(DIR_CURRENT_DIRECTORY /*sdt*/, LPCTSTR NameExten) if (NameExten) { SetNameExtension(NameExten); } } -CPath::CPath(DIR_MODULE_DIRECTORY /*sdt*/, LPCTSTR NameExten) +CPath::CPath(DIR_MODULE_DIRECTORY /*sdt*/, const char * NameExten) { // The directory where the executable of this app is Init(); @@ -249,10 +249,10 @@ CPath::CPath(DIR_MODULE_FILE /*sdt*/) // Do not rely on pNames being <= 8 characters, extensions // being <= 3 characters, or drives being 1 character //------------------------------------------------------------- -void CPath::GetComponents(stdstr* pDrive, - stdstr* pDirectory, - stdstr* pName, - stdstr* pExtension) const +void CPath::GetComponents(std::string* pDrive, + std::string* pDirectory, + std::string* pName, + std::string* pExtension) const { TCHAR buff_drive[_MAX_DRIVE + 1]; TCHAR buff_dir [_MAX_DIR + 1]; @@ -264,7 +264,7 @@ void CPath::GetComponents(stdstr* pDrive, ZeroMemory(buff_name, sizeof(buff_name)); ZeroMemory(buff_ext, sizeof(buff_ext)); - _tsplitpath(m_strPath.c_str(), + _splitpath(m_strPath.c_str(), pDrive ? buff_drive : NULL, pDirectory ? buff_dir : NULL, pName ? buff_name : NULL, @@ -293,10 +293,10 @@ void CPath::GetComponents(stdstr* pDrive, //------------------------------------------------------------- // Task : Get drive and directory from path //------------------------------------------------------------- -void CPath::GetDriveDirectory(stdstr& rDriveDirectory) const +void CPath::GetDriveDirectory(std::string& rDriveDirectory) const { - stdstr Drive; - stdstr Directory; + std::string Drive; + std::string Directory; GetComponents(&Drive,&Directory); rDriveDirectory =Drive; @@ -307,23 +307,23 @@ void CPath::GetDriveDirectory(stdstr& rDriveDirectory) const } } -stdstr CPath::GetDriveDirectory(void) const +std::string CPath::GetDriveDirectory(void) const { - stdstr rDriveDirectory; + std::string rDriveDirectory; GetDriveDirectory(rDriveDirectory); return rDriveDirectory; } //------------------------------------------------------------- // Task : Get directory from path //------------------------------------------------------------- -void CPath::GetDirectory(stdstr& rDirectory) const +void CPath::GetDirectory(std::string& rDirectory) const { GetComponents(NULL,&rDirectory); } -stdstr CPath::GetDirectory(void) const +std::string CPath::GetDirectory(void) const { - stdstr rDirectory; + std::string rDirectory; GetComponents(NULL,&rDirectory); return rDirectory; } @@ -331,10 +331,10 @@ stdstr CPath::GetDirectory(void) const //------------------------------------------------------------- // Task : Get filename and extension from path //------------------------------------------------------------- -void CPath::GetNameExtension(stdstr& rNameExtension) const +void CPath::GetNameExtension(std::string& rNameExtension) const { - stdstr Name; - stdstr Extension; + std::string Name; + std::string Extension; GetComponents(NULL,NULL,&Name,&Extension); rNameExtension =Name; @@ -345,9 +345,9 @@ void CPath::GetNameExtension(stdstr& rNameExtension) const } } -stdstr CPath::GetNameExtension(void) const +std::string CPath::GetNameExtension(void) const { - stdstr rNameExtension; + std::string rNameExtension; GetNameExtension(rNameExtension); return rNameExtension; } @@ -355,14 +355,14 @@ stdstr CPath::GetNameExtension(void) const //------------------------------------------------------------- // Task : Get filename from path //------------------------------------------------------------- -void CPath::GetName(stdstr& rName) const +void CPath::GetName(std::string& rName) const { GetComponents(NULL,NULL,&rName); } -stdstr CPath::GetName(void) const +std::string CPath::GetName(void) const { - stdstr rName; + std::string rName; GetComponents(NULL,NULL,&rName); return rName; } @@ -370,14 +370,14 @@ stdstr CPath::GetName(void) const //------------------------------------------------------------- // Task : Get file extension from path //------------------------------------------------------------- -void CPath::GetExtension(stdstr& rExtension) const +void CPath::GetExtension(std::string& rExtension) const { GetComponents(NULL,NULL,NULL,&rExtension); } -stdstr CPath::GetExtension(void) const +std::string CPath::GetExtension(void) const { - stdstr rExtension; + std::string rExtension; GetComponents(NULL,NULL,NULL,&rExtension); return rExtension; } @@ -385,9 +385,9 @@ stdstr CPath::GetExtension(void) const //------------------------------------------------------------- // Task : Get current directory //------------------------------------------------------------- -void CPath::GetCurrentDirectory(stdstr& rDirectory) const +void CPath::GetCurrentDirectory(std::string& rDirectory) const { - stdstr Directory; + std::string Directory; rDirectory = ""; @@ -396,15 +396,15 @@ void CPath::GetCurrentDirectory(stdstr& rDirectory) const if(Directory.empty()) return; - stdstr::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER); + std::string::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER); rDirectory =Directory.substr(nDelimiter); StripLeadingBackslash(rDirectory); } -stdstr CPath::GetCurrentDirectory(void) const +std::string CPath::GetCurrentDirectory(void) const { - stdstr rDirecotry; + std::string rDirecotry; GetCurrentDirectory(rDirecotry); return rDirecotry; } @@ -412,13 +412,13 @@ stdstr CPath::GetCurrentDirectory(void) const //------------------------------------------------------------- // Task : Get fully qualified path //------------------------------------------------------------- -void CPath::GetFullyQualified(stdstr& rFullyQualified) const +void CPath::GetFullyQualified(std::string& rFullyQualified) const { TCHAR buff_fullname[MAX_PATH]; memset(buff_fullname, 0, sizeof(buff_fullname)); - _tfullpath(buff_fullname,m_strPath.c_str(),MAX_PATH-1); + _fullpath(buff_fullname, m_strPath.c_str(), MAX_PATH - 1); rFullyQualified =buff_fullname; } @@ -426,7 +426,7 @@ void CPath::GetFullyQualified(stdstr& rFullyQualified) const // Post : Return TRUE if path does not start from filesystem root // Task : Check if path is a relative one (e.g. doesn't start with C:\...) //------------------------------------------------------------- -BOOL CPath::IsRelative() const +bool CPath::IsRelative() const { if (m_strPath.length() > 1 && m_strPath[1] == DRIVE_DELIMITER) { @@ -442,16 +442,16 @@ BOOL CPath::IsRelative() const //------------------------------------------------------------- // Task : Set path components //------------------------------------------------------------- -void CPath::SetComponents(LPCTSTR lpszDrive, - LPCTSTR lpszDirectory, - LPCTSTR lpszName, - LPCTSTR lpszExtension) +void CPath::SetComponents(const char * lpszDrive, + const char * lpszDirectory, + const char * lpszName, + const char * lpszExtension) { TCHAR buff_fullname[MAX_PATH]; memset(buff_fullname, 0, sizeof(buff_fullname)); - _tmakepath(buff_fullname,lpszDrive,lpszDirectory,lpszName,lpszExtension); + _makepath(buff_fullname, lpszDrive, lpszDirectory, lpszName, lpszExtension); m_strPath.erase(); m_strPath =buff_fullname; @@ -462,10 +462,10 @@ void CPath::SetComponents(LPCTSTR lpszDrive, //------------------------------------------------------------- void CPath::SetDrive(TCHAR chDrive) { - stdstr_f Drive(_T("%c"),chDrive); - stdstr Directory; - stdstr Name; - stdstr Extension; + stdstr_f Drive("%c",chDrive); + std::string Directory; + std::string Name; + std::string Extension; GetComponents(NULL,&Directory,&Name,&Extension); SetComponents(Drive.c_str(),Directory.c_str(),Name.c_str(),Extension.c_str()); @@ -474,12 +474,12 @@ void CPath::SetDrive(TCHAR chDrive) //------------------------------------------------------------- // Task : Set path's directory //------------------------------------------------------------- -void CPath::SetDirectory(LPCTSTR lpszDirectory, BOOL bEnsureAbsolute /*= FALSE*/) +void CPath::SetDirectory(const char * lpszDirectory, bool bEnsureAbsolute /*= FALSE*/) { - stdstr Drive; - stdstr Directory =lpszDirectory; - stdstr Name; - stdstr Extension; + std::string Drive; + std::string Directory =lpszDirectory; + std::string Name; + std::string Extension; if(bEnsureAbsolute) EnsureLeadingBackslash(Directory); @@ -492,11 +492,11 @@ void CPath::SetDirectory(LPCTSTR lpszDirectory, BOOL bEnsureAbsolute /*= FALSE*/ //------------------------------------------------------------- // Task : Set path's drive and directory //------------------------------------------------------------- -void CPath::SetDriveDirectory(LPCTSTR lpszDriveDirectory) +void CPath::SetDriveDirectory(const char * lpszDriveDirectory) { - stdstr DriveDirectory =lpszDriveDirectory; - stdstr Name; - stdstr Extension; + std::string DriveDirectory =lpszDriveDirectory; + std::string Name; + std::string Extension; EnsureTrailingBackslash(DriveDirectory); cleanPathString(DriveDirectory); @@ -508,11 +508,11 @@ void CPath::SetDriveDirectory(LPCTSTR lpszDriveDirectory) //------------------------------------------------------------- // Task : Set path's filename //------------------------------------------------------------- -void CPath::SetName(LPCTSTR lpszName) +void CPath::SetName(const char * lpszName) { - stdstr Drive; - stdstr Directory; - stdstr Extension; + std::string Drive; + std::string Directory; + std::string Extension; GetComponents(&Drive,&Directory,NULL,&Extension); SetComponents(Drive.c_str(),Directory.c_str(),lpszName,Extension.c_str()); @@ -523,14 +523,14 @@ void CPath::SetName(LPCTSTR lpszName) //------------------------------------------------------------- void CPath::SetName(int iName) { - stdstr Drive; - stdstr Directory; - stdstr Extension; + std::string Drive; + std::string Directory; + std::string Extension; TCHAR sName[33]; memset(sName, 0, sizeof(sName)); - _itot(iName, sName, 10); + _itoa(iName, sName, 10); GetComponents(&Drive,&Directory,NULL,&Extension); SetComponents(Drive.c_str(),Directory.c_str(),sName,Extension.c_str()); @@ -540,11 +540,11 @@ void CPath::SetName(int iName) //------------------------------------------------------------- // Task : Set path's file extension //------------------------------------------------------------- -void CPath::SetExtension(LPCTSTR lpszExtension) +void CPath::SetExtension(const char * lpszExtension) { - stdstr Drive; - stdstr Directory; - stdstr Name; + std::string Drive; + std::string Directory; + std::string Name; GetComponents(&Drive,&Directory,&Name); SetComponents(Drive.c_str(),Directory.c_str(),Name.c_str(),lpszExtension); @@ -555,14 +555,14 @@ void CPath::SetExtension(LPCTSTR lpszExtension) //------------------------------------------------------------- void CPath::SetExtension(int iExtension) { - stdstr Drive; - stdstr Directory; - stdstr Name; + std::string Drive; + std::string Directory; + std::string Name; TCHAR sExtension[20]; memset(sExtension, 0, sizeof(sExtension)); - _itot(iExtension, sExtension, 10); + _itoa(iExtension, sExtension, 10); GetComponents(&Drive,&Directory,&Name); SetComponents(Drive.c_str(),Directory.c_str(),Name.c_str(),sExtension); @@ -571,10 +571,10 @@ void CPath::SetExtension(int iExtension) //------------------------------------------------------------- // Task : Set path's filename and extension //------------------------------------------------------------- -void CPath::SetNameExtension(LPCTSTR lpszNameExtension) +void CPath::SetNameExtension(const char * lpszNameExtension) { - stdstr Drive; - stdstr Directory; + std::string Drive; + std::string Directory; GetComponents(&Drive,&Directory); SetComponents(Drive.c_str(),Directory.c_str(),lpszNameExtension,NULL); @@ -583,13 +583,13 @@ void CPath::SetNameExtension(LPCTSTR lpszNameExtension) //------------------------------------------------------------- // Task : Append a subdirectory 2 path's directory //------------------------------------------------------------- -void CPath::AppendDirectory(LPCTSTR lpszSubDirectory) +void CPath::AppendDirectory(const char * lpszSubDirectory) { - stdstr Drive; - stdstr Directory; - stdstr SubDirectory =lpszSubDirectory; - stdstr Name; - stdstr Extension; + std::string Drive; + std::string Directory; + std::string SubDirectory =lpszSubDirectory; + std::string Name; + std::string Extension; if(SubDirectory.empty()) return; @@ -610,16 +610,16 @@ void CPath::AppendDirectory(LPCTSTR lpszSubDirectory) // deepest directory (the one we're just exiting) in it // Task : Remove deepest subdirectory from path //------------------------------------------------------------- -void CPath::UpDirectory(stdstr *pLastDirectory /*= NULL*/) +void CPath::UpDirectory(std::string *pLastDirectory /*= NULL*/) { - stdstr Directory; + std::string Directory; GetDirectory(Directory); StripTrailingBackslash(Directory); if(Directory.empty()) return; - stdstr::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER); + std::string::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER); if(pLastDirectory != NULL) { @@ -627,7 +627,7 @@ void CPath::UpDirectory(stdstr *pLastDirectory /*= NULL*/) StripLeadingBackslash(*pLastDirectory); } - if(nDelimiter != stdstr::npos) + if(nDelimiter != std::string::npos) Directory =Directory.substr(0,nDelimiter); SetDirectory(Directory.c_str()); @@ -651,13 +651,13 @@ void CPath::CurrentDirectory() //------------------------------------------------------------- // Task : Set path 2 the name of specified module //------------------------------------------------------------- -void CPath::Module(HINSTANCE hInstance) +void CPath::Module(void * hInstance) { TCHAR buff_path[MAX_PATH]; memset(buff_path, 0, sizeof(buff_path)); - GetModuleFileName(hInstance,buff_path,MAX_PATH); + GetModuleFileName((HINSTANCE)hInstance, buff_path, MAX_PATH); m_strPath =buff_path; } @@ -669,17 +669,17 @@ void CPath::Module() TCHAR buff_path[MAX_PATH]; memset(buff_path, 0, sizeof(buff_path)); - GetModuleFileName(m_hInst,buff_path,MAX_PATH); + GetModuleFileName((HMODULE)m_hInst,buff_path,MAX_PATH); m_strPath =buff_path; } //------------------------------------------------------------- // Task : Set path 2 the directory of specified module //------------------------------------------------------------- -void CPath::ModuleDirectory(HINSTANCE hInstance) +void CPath::ModuleDirectory(void * hInstance) { - Module(hInstance); - SetNameExtension(_T("")); + Module((HINSTANCE)hInstance); + SetNameExtension(""); } //------------------------------------------------------------- @@ -688,17 +688,17 @@ void CPath::ModuleDirectory(HINSTANCE hInstance) void CPath::ModuleDirectory() { Module(); - SetNameExtension(_T("")); + SetNameExtension(""); } //--------------------------------------------------------------------------- // Post : Return TRUE if a directory // Task : Check if this path represents a directory //--------------------------------------------------------------------------- -BOOL CPath::IsDirectory() const +bool CPath::IsDirectory() const { // Check if this path has a filename - stdstr file_name; + std::string file_name; GetNameExtension(file_name); return file_name.empty(); @@ -712,18 +712,18 @@ BOOL CPath::IsDirectory() const // use CPath::FindFirst() because that routine parses out // '.' and '..', which fails for empty directories //------------------------------------------------------------- -BOOL CPath::DirectoryExists() const +bool CPath::DirectoryExists() const { // Create test path CPath TestPath(m_strPath.c_str()); - stdstr DirName; + std::string DirName; TestPath.UpDirectory(&DirName); TestPath.SetNameExtension(DirName.c_str()); WIN32_FIND_DATA FindData; - HANDLE hFindFile =FindFirstFile((LPCTSTR)TestPath,&FindData); // Find anything - BOOL bGotFile =(hFindFile != INVALID_HANDLE_VALUE); + HANDLE hFindFile =FindFirstFile((const char *)TestPath,&FindData); // Find anything + bool bGotFile =(hFindFile != INVALID_HANDLE_VALUE); if(hFindFile != NULL) // Make sure we close the search FindClose(hFindFile); @@ -735,11 +735,11 @@ BOOL CPath::DirectoryExists() const // Post : Return TRUE if these is such a file // Task : Check if file exists //------------------------------------------------------------- -BOOL CPath::Exists() const +bool CPath::Exists() const { WIN32_FIND_DATA FindData; HANDLE hFindFile =FindFirstFile(m_strPath.c_str(),&FindData); - BOOL bSuccess =(hFindFile != INVALID_HANDLE_VALUE); + bool bSuccess =(hFindFile != INVALID_HANDLE_VALUE); if(hFindFile != NULL) // Make sure we close the search FindClose(hFindFile); @@ -751,10 +751,10 @@ BOOL CPath::Exists() const // Post : Return TRUE on success // Task : Delete file //------------------------------------------------------------- -BOOL CPath::Delete(BOOL bEvenIfReadOnly) const +bool CPath::Delete(bool bEvenIfReadOnly) const { - ULONG dwAttr =::GetFileAttributes(m_strPath.c_str()); - if(dwAttr == (ULONG)-1) + uint32_t dwAttr =::GetFileAttributes(m_strPath.c_str()); + if(dwAttr == (uint32_t)-1) // File does not exists return FALSE; @@ -763,7 +763,7 @@ BOOL CPath::Delete(BOOL bEvenIfReadOnly) const return FALSE; SetFileAttributes(m_strPath.c_str(),FILE_ATTRIBUTE_NORMAL); - return DeleteFile(m_strPath.c_str()); + return DeleteFile(m_strPath.c_str()) != 0; } //------------------------------------------------------------- @@ -773,7 +773,7 @@ BOOL CPath::Delete(BOOL bEvenIfReadOnly) const // Since ::CopyFile will not overwrite read only files // we will make sure the target file is writable first //------------------------------------------------------------- -BOOL CPath::CopyTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite) +bool CPath::CopyTo(const char * lpcszTargetFile, bool bOverwrite) { // Check if the target file exists CPath TargetFile(lpcszTargetFile); @@ -791,7 +791,7 @@ BOOL CPath::CopyTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite) // CopyFile will set the target's attributes 2 the same as // the source after copying - return CopyFile(m_strPath.c_str(),lpcszTargetFile,!bOverwrite); + return CopyFile(m_strPath.c_str(),lpcszTargetFile,!bOverwrite) != 0; } //------------------------------------------------------------- @@ -799,7 +799,7 @@ BOOL CPath::CopyTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite) // and we weren't granted permission 2 overwrite file or some error // Task : Move file //------------------------------------------------------------- -BOOL CPath::MoveTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite) +bool CPath::MoveTo(const char * lpcszTargetFile, bool bOverwrite) { // Check if the target file exists CPath TargetFile(lpcszTargetFile); @@ -815,14 +815,14 @@ BOOL CPath::MoveTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite) return FALSE; } - return MoveFile(m_strPath.c_str(),lpcszTargetFile); + return MoveFile(m_strPath.c_str(),lpcszTargetFile) != 0; } //------------------------------------------------------------- // Post : Return TRUE if attributes do match // Task : Compare finder attributes //------------------------------------------------------------- -BOOL CPath::AttributesMatch(ULONG dwTargetAttributes, ULONG dwFileAttributes) +bool CPath::AttributesMatch(uint32_t dwTargetAttributes, uint32_t dwFileAttributes) { if (dwTargetAttributes == _A_ALLFILES) { @@ -863,7 +863,7 @@ BOOL CPath::AttributesMatch(ULONG dwTargetAttributes, ULONG dwFileAttributes) // if you specify those attributes // See aso: FindFirstFile, FindNextFile //------------------------------------------------------------- -BOOL CPath::FindFirst(ULONG dwAttributes /*= _A_NORMAL*/) +bool CPath::FindFirst(uint32_t dwAttributes /*= _A_NORMAL*/) { m_dwFindFileAttributes =dwAttributes; BOOL bGotFile; @@ -908,7 +908,7 @@ BOOL CPath::FindFirst(ULONG dwAttributes /*= _A_NORMAL*/) // Task : Find the next file that meets the conditions specified // in the last FindFirst call //------------------------------------------------------------- -BOOL CPath::FindNext() +bool CPath::FindNext() { if (m_hFindFile == NULL) return FALSE; @@ -955,12 +955,12 @@ BOOL CPath::FindNext() // Post : Return TRUE on success // Task : Change current working directory of application 2 path //------------------------------------------------------------- -BOOL CPath::ChangeDirectory() +bool CPath::ChangeDirectory() { - stdstr DriveDirectory; + std::string DriveDirectory; GetDriveDirectory(DriveDirectory); - return SetCurrentDirectory(DriveDirectory.c_str()); + return SetCurrentDirectory(DriveDirectory.c_str()) != 0; } //------------------------------------------------------------- @@ -969,32 +969,32 @@ BOOL CPath::ChangeDirectory() // Post : Return TRUE on success // Task : Create new directory //------------------------------------------------------------- -BOOL CPath::CreateDirectory(BOOL bCreateIntermediates /*= TRUE*/) +bool CPath::DirectoryCreate(bool bCreateIntermediates /*= TRUE*/) { - stdstr PathText; - BOOL bSuccess; + std::string PathText; + bool bSuccess; GetDriveDirectory(PathText); StripTrailingBackslash(PathText); - bSuccess =::CreateDirectory(PathText.c_str(),NULL); + bSuccess =::CreateDirectory(PathText.c_str(),NULL) != 0; if(!bSuccess) { CPath CurrentDir(CPath::CURRENT_DIRECTORY); - bSuccess = ChangeDirectory(); + bSuccess = ChangeDirectory() != 0; CurrentDir.ChangeDirectory(); } if(!bSuccess && bCreateIntermediates) { - stdstr::size_type nDelimiter =PathText.rfind(DIRECTORY_DELIMITER); - if(nDelimiter == stdstr::npos) + std::string::size_type nDelimiter =PathText.rfind(DIRECTORY_DELIMITER); + if(nDelimiter == std::string::npos) return FALSE; PathText.resize(nDelimiter + 1); CPath SubPath(PathText); - if(SubPath.CreateDirectory()) - return CreateDirectory(FALSE); + if (SubPath.DirectoryCreate()) + return DirectoryCreate(false); else return FALSE; } @@ -1007,7 +1007,7 @@ BOOL CPath::CreateDirectory(BOOL bCreateIntermediates /*= TRUE*/) //------------------------------------------------------------------------ // Task : Remove first character (if any) if it's chLeading //------------------------------------------------------------------------ -void CPath::cleanPathString(stdstr& rDirectory) const +void CPath::cleanPathString(std::string& rDirectory) const { LPCSTR const DIR_DOUBLEDELIM = "\\\\"; @@ -1031,9 +1031,9 @@ void CPath::cleanPathString(stdstr& rDirectory) const } } -void CPath::StripLeadingChar(stdstr& rText, TCHAR chLeading) const +void CPath::StripLeadingChar(std::string& rText, TCHAR chLeading) const { - stdstr::size_type nLength =rText.length(); + std::string::size_type nLength =rText.length(); if(nLength == 0) return; @@ -1045,9 +1045,9 @@ void CPath::StripLeadingChar(stdstr& rText, TCHAR chLeading) const //------------------------------------------------------------------------ // Task : Remove first character if \ //------------------------------------------------------------------------ -void CPath::StripLeadingBackslash(stdstr& Directory) const +void CPath::StripLeadingBackslash(std::string& Directory) const { - stdstr::size_type nLength =Directory.length(); + std::string::size_type nLength =Directory.length(); // If Directory is of the form '\', don't do it if(nLength <= 1) @@ -1060,9 +1060,9 @@ void CPath::StripLeadingBackslash(stdstr& Directory) const //------------------------------------------------------------------------ // Task : Remove last character (if any) if it's chTrailing //------------------------------------------------------------------------ -void CPath::StripTrailingChar(stdstr& rText, TCHAR chTrailing) const +void CPath::StripTrailingChar(std::string& rText, TCHAR chTrailing) const { - stdstr::size_type nLength =rText.length(); + std::string::size_type nLength =rText.length(); if(nLength == 0) return; @@ -1073,11 +1073,11 @@ void CPath::StripTrailingChar(stdstr& rText, TCHAR chTrailing) const //------------------------------------------------------------------------ // Task : Remove last character if \ //------------------------------------------------------------------------ -void CPath::StripTrailingBackslash(stdstr& rDirectory) const +void CPath::StripTrailingBackslash(std::string& rDirectory) const { for (;;) { - stdstr::size_type nLength = rDirectory.length(); + std::string::size_type nLength = rDirectory.length(); if(nLength <= 1) { return; @@ -1096,23 +1096,24 @@ void CPath::StripTrailingBackslash(stdstr& rDirectory) const // Task : Add a backslash to the end of Directory if there is // not already one there //------------------------------------------------------------------------ -void CPath::EnsureTrailingBackslash(stdstr& Directory) const +void CPath::EnsureTrailingBackslash(std::string& Directory) const { - stdstr::size_type nLength =Directory.length(); + std::string::size_type nLength = Directory.length(); - if(Directory.empty() || (Directory[nLength-1] != DIRECTORY_DELIMITER)) - Directory +=DIRECTORY_DELIMITER; + if (Directory.empty() || (Directory[nLength - 1] != DIRECTORY_DELIMITER)) + { + Directory += DIRECTORY_DELIMITER; + } } //------------------------------------------------------------------------ // Task : Add a backslash to the beginning of Directory if there // is not already one there //------------------------------------------------------------------------ -void CPath::EnsureLeadingBackslash(stdstr& Directory) const +void CPath::EnsureLeadingBackslash(std::string & Directory) const { if(Directory.empty() || (Directory[0] != DIRECTORY_DELIMITER)) { - stdstr temp =Directory; - Directory.Format(_T("%c%s"),DIRECTORY_DELIMITER,temp.c_str()); + Directory = stdstr_f("%c%s", DIRECTORY_DELIMITER, Directory.c_str()); } } diff --git a/Source/Common/path.h b/Source/Common/path.h index de1f8919c..186e3133b 100644 --- a/Source/Common/path.h +++ b/Source/Common/path.h @@ -1,32 +1,14 @@ -////////////////////////////////////////////////////////////////////// -// -// Handy routines to help with file & path management -// -// This class is used to represent pathnames, that is the name and -// location of a file. CPaths are used when you want to refer to a file -// as a whole, or to the location of a file. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_PATH_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_) -#define AFX_PATH_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - -#include "std string.h" -#include -#include -#include +#include +#include "stdtypes.h" class CPathException { public: - ULONG m_dwErrorCode; + uint32_t m_dwErrorCode; public: - CPathException(ULONG code =0): m_dwErrorCode(code) {} + CPathException(uint32_t code =0): m_dwErrorCode(code) {} }; class CPath @@ -43,10 +25,10 @@ public: //Attributes private: - stdstr m_strPath; - ULONG m_dwFindFileAttributes; - HANDLE m_hFindFile; - static HINSTANCE m_hInst; + std::string m_strPath; + uint32_t m_dwFindFileAttributes; + void * m_hFindFile; + static void * m_hInst; public: //Methods @@ -54,15 +36,15 @@ public: //Construction / destruction CPath(); CPath(const CPath& rPath); - CPath(LPCTSTR lpszPath); - CPath(LPCTSTR lpszPath, LPCTSTR NameExten); - CPath(LPCTSTR lpszPath, const stdstr& NameExten); - CPath(const stdstr& strPath); - CPath(const stdstr& strPath, LPCTSTR NameExten); - CPath(const stdstr& strPath, const stdstr& NameExten); + CPath(const char * lpszPath); + CPath(const char * lpszPath, const char * NameExten); + CPath(const char * lpszPath, const std::string & NameExten); + CPath(const std::string& strPath); + CPath(const std::string& strPath, const char * NameExten); + CPath(const std::string& strPath, const std::string& NameExten); - CPath(DIR_CURRENT_DIRECTORY sdt, LPCTSTR NameExten = NULL); - CPath(DIR_MODULE_DIRECTORY sdt, LPCTSTR NameExten = NULL); + CPath(DIR_CURRENT_DIRECTORY sdt, const char * NameExten = NULL); + CPath(DIR_MODULE_DIRECTORY sdt, const char * NameExten = NULL); CPath(DIR_MODULE_FILE sdt); virtual ~CPath(); @@ -73,95 +55,93 @@ public: //Operators CPath& operator = (const CPath& rPath); - CPath& operator = (LPCTSTR lpszPath); - CPath& operator = (const stdstr& strPath); - BOOL operator == (const CPath& rPath) const; - BOOL operator != (const CPath& rPath) const; - operator LPCTSTR() const; - operator stdstr&() { return m_strPath; } + CPath& operator = (const char * lpszPath); + CPath& operator = (const std::string & strPath); + bool operator == (const CPath& rPath) const; + bool operator != (const CPath& rPath) const; + operator const char *() const; + operator std::string &() { return m_strPath; } //Get path components - void GetDriveDirectory(stdstr& rDriveDirectory) const; - stdstr GetDriveDirectory(void) const; - void GetDirectory(stdstr& rDirectory) const; - stdstr GetDirectory(void) const; - void GetName(stdstr& rName) const; - stdstr GetName(void) const; - void GetNameExtension(stdstr& rNameExtension) const; - stdstr GetNameExtension(void) const; - void GetExtension(stdstr& rExtension) const; - stdstr GetExtension(void) const; - void GetCurrentDirectory(stdstr& rDrive) const; - stdstr GetCurrentDirectory(void) const; - void GetFullyQualified(stdstr& rFullyQualified) const; - void GetComponents(stdstr* pDrive =NULL, - stdstr* pDirectory =NULL, - stdstr* pName =NULL, - stdstr* pExtension =NULL) const; + void GetDriveDirectory(std::string & rDriveDirectory) const; + std::string GetDriveDirectory(void) const; + void GetDirectory(std::string& rDirectory) const; + std::string GetDirectory(void) const; + void GetName(std::string& rName) const; + std::string GetName(void) const; + void GetNameExtension(std::string& rNameExtension) const; + std::string GetNameExtension(void) const; + void GetExtension(std::string& rExtension) const; + std::string GetExtension(void) const; + void GetCurrentDirectory(std::string& rDrive) const; + std::string GetCurrentDirectory(void) const; + void GetFullyQualified(std::string& rFullyQualified) const; + void GetComponents(std::string* pDrive = NULL, + std::string* pDirectory =NULL, + std::string* pName = NULL, + std::string* pExtension = NULL) const; //Get other state - BOOL IsEmpty() const { return m_strPath.empty(); } - BOOL IsRelative() const; + bool IsEmpty() const { return m_strPath.empty(); } + bool IsRelative() const; //Set path components - void SetDrive(TCHAR chDrive); - void SetDriveDirectory(LPCTSTR lpszDriveDirectory); - void SetDirectory(LPCTSTR lpszDirectory, BOOL bEnsureAbsolute =FALSE); - void SetName(LPCTSTR lpszName); + void SetDrive(char chDrive); + void SetDriveDirectory(const char * lpszDriveDirectory); + void SetDirectory(const char * lpszDirectory, bool bEnsureAbsolute = false); + void SetName(const char * lpszName); void SetName(int iName); - void SetNameExtension(LPCTSTR lpszNameExtension); - void SetExtension(LPCTSTR lpszExtension); + void SetNameExtension(const char * lpszNameExtension); + void SetExtension(const char * lpszExtension); void SetExtension(int iExtension); - void AppendDirectory(LPCTSTR lpszSubDirectory); - void UpDirectory(stdstr* pLastDirectory =NULL); - void SetComponents(LPCTSTR lpszDrive, - LPCTSTR lpszDirectory, - LPCTSTR lpszName, - LPCTSTR lpszExtension); + void AppendDirectory(const char * lpszSubDirectory); + void UpDirectory(std::string* pLastDirectory = NULL); + void SetComponents(const char * lpszDrive, + const char * lpszDirectory, + const char * lpszName, + const char * lpszExtension); //Set whole path void Empty() { m_strPath.erase(); } void CurrentDirectory(); void Module(); - void Module(HINSTANCE hInstance); + void Module(void * hInstance); void ModuleDirectory(); - void ModuleDirectory(HINSTANCE hInstance); + void ModuleDirectory(void * hInstance); //Directory information - BOOL IsDirectory() const; - BOOL DirectoryExists() const; + bool IsDirectory() const; + bool DirectoryExists() const; //File Information - BOOL IsFile() const { return !IsDirectory(); } - BOOL Exists() const; + bool IsFile() const { return !IsDirectory(); } + bool Exists() const; //Directory operations - BOOL CreateDirectory(BOOL bCreateIntermediates =TRUE); - BOOL ChangeDirectory(); + bool DirectoryCreate(bool bCreateIntermediates = true); + bool ChangeDirectory(); //File operations - BOOL Delete(BOOL bEvenIfReadOnly =TRUE) const; - BOOL CopyTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite =TRUE); - BOOL MoveTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite =TRUE); + bool Delete(bool bEvenIfReadOnly = true) const; + bool CopyTo(const char * lpcszTargetFile, bool bOverwrite = true); + bool MoveTo(const char * lpcszTargetFile, bool bOverwrite = true); //Finders - BOOL FindFirst(ULONG dwAttributes =_A_NORMAL); - BOOL FindNext(); + bool FindFirst(uint32_t dwAttributes = 0); + bool FindNext(); // Helpers - static void SethInst ( HINSTANCE hInst ); - static HINSTANCE GethInst(); + static void SethInst(void * hInst); + static void * GethInst(); private: - BOOL AttributesMatch(ULONG dwTargetAttributes, ULONG dwFileAttributes); + bool AttributesMatch(uint32_t dwTargetAttributes, uint32_t dwFileAttributes); - void cleanPathString(stdstr& rDirectory) const; - void StripLeadingChar(stdstr& rText, TCHAR chLeading) const; - void StripLeadingBackslash(stdstr& Directory) const; - void StripTrailingChar(stdstr& rText, TCHAR chTrailing) const; - void StripTrailingBackslash(stdstr& rDirectory) const; - void EnsureTrailingBackslash(stdstr& Directory) const; - void EnsureLeadingBackslash(stdstr& Directory) const; + void cleanPathString(std::string& rDirectory) const; + void StripLeadingChar(std::string& rText, char chLeading) const; + void StripLeadingBackslash(std::string& Directory) const; + void StripTrailingChar(std::string& rText, char chTrailing) const; + void StripTrailingBackslash(std::string& rDirectory) const; + void EnsureTrailingBackslash(std::string& Directory) const; + void EnsureLeadingBackslash(std::string& Directory) const; }; - -#endif // !defined(AFX_PATH_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_) diff --git a/Source/Common/stdafx.h b/Source/Common/stdafx.h index eb4efd627..e601c4074 100644 --- a/Source/Common/stdafx.h +++ b/Source/Common/stdafx.h @@ -2,7 +2,6 @@ #include #include -#include #include #include diff --git a/Source/GlideHQ/TxCache.cpp b/Source/GlideHQ/TxCache.cpp index 0df72c381..1c2832da7 100644 --- a/Source/GlideHQ/TxCache.cpp +++ b/Source/GlideHQ/TxCache.cpp @@ -29,6 +29,7 @@ #include "TxDbg.h" #include #include +#include TxCache::~TxCache() { @@ -233,7 +234,7 @@ TxCache::save(const wchar_t *path, const wchar_t *filename, int config) char cbuf[MAX_PATH]; CPath cachepath(stdstr().FromUTF16(path),""); - cachepath.CreateDirectory(); + cachepath.DirectoryCreate(); /* Ugly hack to enable fopen/gzopen in Win9x */ #ifdef _WIN32 diff --git a/Source/GlideHQ/TxFilter.cpp b/Source/GlideHQ/TxFilter.cpp index 68108a237..6600aa39f 100644 --- a/Source/GlideHQ/TxFilter.cpp +++ b/Source/GlideHQ/TxFilter.cpp @@ -26,6 +26,7 @@ #endif #include +#include #include "TxFilter.h" #include "TextureFilters.h" #include "TxDbg.h" @@ -613,15 +614,15 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf /* create directories */ tmpbuf.AppendDirectory("texture_dump"); - if (!tmpbuf.DirectoryExists() && !tmpbuf.CreateDirectory()) + if (!tmpbuf.DirectoryExists() && !tmpbuf.DirectoryCreate()) return 0; tmpbuf.AppendDirectory(stdstr().FromUTF16(_ident.c_str()).c_str()); - if (!tmpbuf.DirectoryExists() && !tmpbuf.CreateDirectory()) + if (!tmpbuf.DirectoryExists() && !tmpbuf.DirectoryCreate()) return 0; tmpbuf.AppendDirectory("GlideHQ"); - if (!tmpbuf.DirectoryExists() && !tmpbuf.CreateDirectory()) + if (!tmpbuf.DirectoryExists() && !tmpbuf.DirectoryCreate()) return 0; if ((n64fmt >> 8) == 0x2) { diff --git a/Source/GlideHQ/TxHiResCache.cpp b/Source/GlideHQ/TxHiResCache.cpp index e4ada0893..27dc4a39e 100644 --- a/Source/GlideHQ/TxHiResCache.cpp +++ b/Source/GlideHQ/TxHiResCache.cpp @@ -61,6 +61,8 @@ #include #include #include +#include +#include TxHiResCache::~TxHiResCache() { @@ -73,7 +75,7 @@ TxHiResCache::~TxHiResCache() cachepath.AppendDirectory("cache"); int config = _options & (HIRESTEXTURES_MASK|COMPRESS_HIRESTEX|COMPRESSION_MASK|TILE_HIRESTEX|FORCE16BPP_HIRESTEX|GZ_HIRESTEXCACHE|LET_TEXARTISTS_FLY); - TxCache::save(stdstr(cachepath).ToUTF16().c_str(), filename.c_str(), config); + TxCache::save(stdstr((std::string &)cachepath).ToUTF16().c_str(), filename.c_str(), config); } #endif @@ -115,7 +117,7 @@ TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, cachepath.AppendDirectory("cache"); int config = _options & (HIRESTEXTURES_MASK|COMPRESS_HIRESTEX|COMPRESSION_MASK|TILE_HIRESTEX|FORCE16BPP_HIRESTEX|GZ_HIRESTEXCACHE|LET_TEXARTISTS_FLY); - _haveCache = TxCache::load(stdstr(cachepath).ToUTF16().c_str(), filename.c_str(), config); + _haveCache = TxCache::load(stdstr((std::string &)cachepath).ToUTF16().c_str(), filename.c_str(), config); } #endif @@ -236,7 +238,7 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace) /* read in Rice's file naming convention */ #define CRCFMTSIZ_LEN 13 #define PALCRC_LEN 9 - wcstombs(fname, TextureDir.GetNameExtension().ToUTF16().c_str(), MAX_PATH); + wcstombs(fname, stdstr(TextureDir.GetNameExtension()).ToUTF16().c_str(), MAX_PATH); /* XXX case sensitivity fiasco! * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci * and file extensions must be in lower case letters! */ diff --git a/Source/GlideHQ/TxTexCache.cpp b/Source/GlideHQ/TxTexCache.cpp index 68e526402..cdceee980 100644 --- a/Source/GlideHQ/TxTexCache.cpp +++ b/Source/GlideHQ/TxTexCache.cpp @@ -33,6 +33,7 @@ #include #include #include +#include TxTexCache::~TxTexCache() { @@ -45,7 +46,7 @@ TxTexCache::~TxTexCache() int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE); - TxCache::save(stdstr(cachepath).ToUTF16().c_str(), filename.c_str(), config); + TxCache::save(stdstr((std::string &)cachepath).ToUTF16().c_str(), filename.c_str(), config); } #endif } @@ -66,7 +67,7 @@ TxTexCache::TxTexCache(int options, int cachesize, const wchar_t *path, const wc cachepath.AppendDirectory("cache"); int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE); - TxCache::load(stdstr(cachepath).ToUTF16().c_str(), filename.c_str(), config); + TxCache::load(stdstr((std::string &)cachepath).ToUTF16().c_str(), filename.c_str(), config); } #endif } diff --git a/Source/Project64/N64 System/Mips/Eeprom.cpp b/Source/Project64/N64 System/Mips/Eeprom.cpp index 75bbad70a..0dfa07c54 100644 --- a/Source/Project64/N64 System/Mips/Eeprom.cpp +++ b/Source/Project64/N64 System/Mips/Eeprom.cpp @@ -149,7 +149,7 @@ void CEeprom::LoadEeprom() if (!FileName.DirectoryExists()) { - FileName.CreateDirectory(); + FileName.DirectoryCreate(); } m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, diff --git a/Source/Project64/N64 System/Mips/FlashRam.cpp b/Source/Project64/N64 System/Mips/FlashRam.cpp index 1b9e50cad..19644dc24 100644 --- a/Source/Project64/N64 System/Mips/FlashRam.cpp +++ b/Source/Project64/N64 System/Mips/FlashRam.cpp @@ -139,7 +139,7 @@ bool CFlashram::LoadFlashram() if (!FileName.DirectoryExists()) { - FileName.CreateDirectory(); + FileName.DirectoryCreate(); } m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, diff --git a/Source/Project64/N64 System/Mips/Mempak.cpp b/Source/Project64/N64 System/Mips/Mempak.cpp index 01d37a13d..83470cc43 100644 --- a/Source/Project64/N64 System/Mips/Mempak.cpp +++ b/Source/Project64/N64 System/Mips/Mempak.cpp @@ -43,7 +43,7 @@ void LoadMempak (int Control) if (!FileName.DirectoryExists()) { - FileName.CreateDirectory(); + FileName.DirectoryCreate(); } BYTE Initialize[] = { diff --git a/Source/Project64/N64 System/Mips/Sram.cpp b/Source/Project64/N64 System/Mips/Sram.cpp index 43777b108..fc70b7f96 100644 --- a/Source/Project64/N64 System/Mips/Sram.cpp +++ b/Source/Project64/N64 System/Mips/Sram.cpp @@ -36,7 +36,7 @@ bool CSram::LoadSram() if (!FileName.DirectoryExists()) { - FileName.CreateDirectory(); + FileName.DirectoryCreate(); } m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS, diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index 2c49e8366..e4f08c84a 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -387,7 +387,7 @@ bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const if (CopyFile(srcGfxPlugin,dstGfxPlugin,false) == 0) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstGfxPlugin.CreateDirectory(); } + if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstGfxPlugin.DirectoryCreate(); } if (!CopyFile(srcGfxPlugin,dstGfxPlugin,false)) { return false; @@ -398,7 +398,7 @@ bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const CPath srcAudioPlugin(m_PluginDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); if (CopyFile(srcAudioPlugin,dstAudioPlugin,false) == 0) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstAudioPlugin.CreateDirectory(); } + if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstAudioPlugin.DirectoryCreate(); } if (!CopyFile(srcAudioPlugin,dstAudioPlugin,false)) { return false; @@ -409,7 +409,7 @@ bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); CPath dstRSPPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); if (CopyFile(srcRSPPlugin,dstRSPPlugin,false) == 0) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstRSPPlugin.CreateDirectory(); } + if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstRSPPlugin.DirectoryCreate(); } if (!CopyFile(srcRSPPlugin,dstRSPPlugin,false)) { return false; @@ -421,7 +421,7 @@ bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const CPath dstContPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); if (!srcContPlugin.CopyTo(dstContPlugin)) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstContPlugin.CreateDirectory(); } + if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstContPlugin.DirectoryCreate(); } if (!CopyFile(srcContPlugin,dstContPlugin,false)) { DWORD dwError = GetLastError(); diff --git a/Source/Project64/Plugins/Plugin List.h b/Source/Project64/Plugins/Plugin List.h index 510510bc0..17edd39c3 100644 --- a/Source/Project64/Plugins/Plugin List.h +++ b/Source/Project64/Plugins/Plugin List.h @@ -3,21 +3,14 @@ class CPluginList { public: - typedef struct { + typedef struct + { PLUGIN_INFO Info; bool AboutFunction; CPath FullPath; stdstr FileName; } PLUGIN; -private: - typedef std::vector PluginList; - - PluginList m_PluginList; - CPath m_PluginDir; - - void AddPluginFromDir ( CPath Dir); - public: CPluginList(bool bAutoFill = true); ~CPluginList(); @@ -26,4 +19,12 @@ public: int GetPluginCount ( void ) const; const PLUGIN * GetPluginInfo ( int indx ) const; static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo ); + +private: + typedef std::vector PluginList; + + PluginList m_PluginList; + CPath m_PluginDir; + + void AddPluginFromDir(CPath Dir); }; diff --git a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp index b33ecf8c3..98f0634be 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp @@ -81,7 +81,7 @@ void CSettingTypeApplication::Initialize( const char * /*AppName*/ ) CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(),""); if (!SettingsDir.DirectoryExists()) { - SettingsDir.CreateDirectory(); + SettingsDir.DirectoryCreate(); } m_SettingsIniFile = new CIniFile(SettingsFile.c_str()); diff --git a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp index adedf7fbc..ed907c7e1 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp @@ -11,8 +11,9 @@ #include "stdafx.h" #include "SettingsType-Application.h" #include "SettingsType-ApplicationPath.h" +#include -CSettingTypeApplicationPath::CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, SettingID DefaultSetting ) : +CSettingTypeApplicationPath::CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting ) : CSettingTypeApplication(Section,Name,DefaultSetting) { @@ -34,7 +35,7 @@ bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str()); FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str()); - Value = FullFilePath; + Value = (std::string &)FullFilePath; } } return bRes; diff --git a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h index e37bd34d2..65e1bf2c6 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h +++ b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h @@ -11,19 +11,22 @@ #pragma once class CSettingTypeApplicationPath : - public CSettingTypeApplication + public CSettingTypeApplication { -private: - CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, LPCSTR DefaultValue ); - CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, bool DefaultValue ); - CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, DWORD DefaultValue ); - public: - virtual ~CSettingTypeApplicationPath(); + virtual ~CSettingTypeApplicationPath(); - CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, SettingID DefaultSetting ); + CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting ); - //return the values - virtual bool Load ( int Index, stdstr & Value ) const; + //return the values + virtual bool Load ( int Index, stdstr & Value ) const; + +private: + CSettingTypeApplicationPath(void); // Disable default constructor + CSettingTypeApplicationPath(const CSettingTypeApplicationPath&); // Disable copy constructor + CSettingTypeApplicationPath& operator=(const CSettingTypeApplicationPath&); // Disable assignment + + CSettingTypeApplicationPath(const char * Section, const char * Name, const char * DefaultValue ); + CSettingTypeApplicationPath(const char * Section, const char * Name, bool DefaultValue ); + CSettingTypeApplicationPath(const char * Section, const char * Name, uint32_t DefaultValue ); }; - diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp index b8bd5b687..0e48cbba7 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp @@ -12,102 +12,101 @@ #include "SettingsType-RomDatabase.h" #include "SettingsType-RDBOnOff.h" -CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(LPCSTR Name, SettingID DefaultSetting ) : - CSettingTypeRomDatabase(Name,DefaultSetting) +CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting ) : + CSettingTypeRomDatabase(Name,DefaultSetting) { } -CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(LPCSTR Name, int DefaultValue ) : - CSettingTypeRomDatabase(Name,DefaultValue) +CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, int DefaultValue ) : + CSettingTypeRomDatabase(Name,DefaultValue) { } - CSettingTypeRDBOnOff::~CSettingTypeRDBOnOff() +CSettingTypeRDBOnOff::~CSettingTypeRDBOnOff() { } bool CSettingTypeRDBOnOff::Load ( int Index, bool & Value ) const { - stdstr strValue; - bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); - if (!bRes) - { - LoadDefault(Index,Value); - return false; - } - LPCSTR String = strValue.c_str(); + stdstr strValue; + bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); + if (!bRes) + { + LoadDefault(Index,Value); + return false; + } + const char * String = strValue.c_str(); - if (_stricmp(String,"On") == 0) { Value = true; } - else if (_stricmp(String,"Off") == 0) { Value = false; } - else if (_stricmp(String,"Global") == 0 || _stricmp(String,"default")) - { - LoadDefault(Index,Value); - return false; - } - else { Notify().BreakPoint(__FILEW__,__LINE__); } - - return true; + if (_stricmp(String,"On") == 0) { Value = true; } + else if (_stricmp(String,"Off") == 0) { Value = false; } + else if (_stricmp(String,"Global") == 0 || _stricmp(String,"default")) + { + LoadDefault(Index,Value); + return false; + } + else { g_Notify->BreakPoint(__FILEW__,__LINE__); } + + return true; } -bool CSettingTypeRDBOnOff::Load ( int /*Index*/, ULONG & /*Value*/ ) const +bool CSettingTypeRDBOnOff::Load ( int /*Index*/, uint32_t & /*Value*/ ) const { - Notify().BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; } bool CSettingTypeRDBOnOff::Load ( int /*Index*/, stdstr & /*Value*/ ) const { - Notify().BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; } //return the default values void CSettingTypeRDBOnOff::LoadDefault ( int /*Index*/, bool & Value ) const { - if (m_DefaultSetting != Default_None) - { - if (m_DefaultSetting == Default_Constant) - { - Value = m_DefaultValue != 0; - } else { - g_Settings->LoadBool(m_DefaultSetting,Value); - } - } + if (m_DefaultSetting != Default_None) + { + if (m_DefaultSetting == Default_Constant) + { + Value = m_DefaultValue != 0; + } else { + g_Settings->LoadBool(m_DefaultSetting,Value); + } + } } -void CSettingTypeRDBOnOff::LoadDefault ( int /*Index*/, ULONG & /*Value*/ ) const +void CSettingTypeRDBOnOff::LoadDefault ( int /*Index*/, uint32_t & /*Value*/ ) const { - Notify().BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } void CSettingTypeRDBOnOff::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) const { - Notify().BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } - //Update the settings void CSettingTypeRDBOnOff::Save ( int /*Index*/, bool Value ) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "On" : "Off"); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "On" : "Off"); } -void CSettingTypeRDBOnOff::Save ( int /*Index*/, ULONG /*Value*/ ) +void CSettingTypeRDBOnOff::Save ( int /*Index*/, uint32_t /*Value*/ ) { - Notify().BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } void CSettingTypeRDBOnOff::Save ( int /*Index*/, const stdstr & /*Value*/ ) { - Notify().BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } void CSettingTypeRDBOnOff::Save ( int /*Index*/, const char * /*Value*/ ) { - Notify().BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } void CSettingTypeRDBOnOff::Delete( int /*Index*/ ) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),NULL); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),NULL); } diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h index 5c21d301c..46f91bed4 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h @@ -11,31 +11,34 @@ #pragma once class CSettingTypeRDBOnOff : - public CSettingTypeRomDatabase + public CSettingTypeRomDatabase { - public: - CSettingTypeRDBOnOff(LPCSTR Name, SettingID DefaultSetting ); - CSettingTypeRDBOnOff(LPCSTR Name, int DefaultValue ); - ~CSettingTypeRDBOnOff(); + CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting ); + CSettingTypeRDBOnOff(const char * Name, int DefaultValue ); + ~CSettingTypeRDBOnOff(); - //return the values - virtual bool Load ( int Index, bool & Value ) const; - virtual bool Load ( int Index, ULONG & Value ) const; - virtual bool Load ( int Index, stdstr & Value ) const; + //return the values + virtual bool Load ( int Index, bool & Value ) const; + virtual bool Load ( int Index, uint32_t & Value ) const; + virtual bool Load ( int Index, stdstr & Value ) const; - //return the default values - virtual void LoadDefault ( int Index, bool & Value ) const; - virtual void LoadDefault ( int Index, ULONG & Value ) const; - virtual void LoadDefault ( int Index, stdstr & Value ) const; + //return the default values + virtual void LoadDefault ( int Index, bool & Value ) const; + virtual void LoadDefault ( int Index, uint32_t & Value ) const; + virtual void LoadDefault ( int Index, stdstr & Value ) const; - //Update the settings - virtual void Save ( int Index, bool Value ); - virtual void Save ( int Index, ULONG Value ); - virtual void Save ( int Index, const stdstr & Value ); - virtual void Save ( int Index, const char * Value ); + //Update the settings + virtual void Save ( int Index, bool Value ); + virtual void Save ( int Index, uint32_t Value ); + virtual void Save ( int Index, const stdstr & Value ); + virtual void Save ( int Index, const char * Value ); - // Delete the setting - virtual void Delete ( int Index ); + // Delete the setting + virtual void Delete ( int Index ); + +private: + CSettingTypeRDBOnOff(void); // Disable default constructor + CSettingTypeRDBOnOff(const CSettingTypeRDBOnOff&); // Disable copy constructor + CSettingTypeRDBOnOff& operator=(const CSettingTypeRDBOnOff&); // Disable assignment }; - diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp index f8f81d2d1..3c4acaef2 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp @@ -12,13 +12,13 @@ #include "SettingsType-RomDatabase.h" #include "SettingsType-RDBYesNo.h" -CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(LPCSTR Name, SettingID DefaultSetting ) : - CSettingTypeRomDatabase(Name,DefaultSetting) +CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(const char * Name, SettingID DefaultSetting ) : + CSettingTypeRomDatabase(Name,DefaultSetting) { } -CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(LPCSTR Name, int DefaultValue ) : - CSettingTypeRomDatabase(Name,DefaultValue) +CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(const char * Name, int DefaultValue ) : + CSettingTypeRomDatabase(Name,DefaultValue) { } @@ -28,89 +28,96 @@ CSettingTypeRDBYesNo::~CSettingTypeRDBYesNo() bool CSettingTypeRDBYesNo::Load ( int Index, bool & Value ) const { - stdstr strValue; - bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); - if (!bRes) - { - LoadDefault(Index,Value); - return false; - } - LPCSTR String = strValue.c_str(); + stdstr strValue; + bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); + if (!bRes) + { + LoadDefault(Index,Value); + return false; + } + const char * String = strValue.c_str(); - if (_stricmp(String,"Yes") == 0) { Value = true; } - else if (_stricmp(String,"No") == 0) { Value = false; } - else if (_stricmp(String,"default") == 0) - { - LoadDefault(Index,Value); - return false; - } else { - WriteTraceF(TraceError,__FUNCTION__ ": Invalid Yes/No setting value (Section: %s Key: %s Value: %s)",m_SectionIdent->c_str(),String,m_KeyName.c_str(),strValue.c_str()); - LoadDefault(Index,Value); - return false; - } - - return true; + if (_stricmp(String,"Yes") == 0) + { + Value = true; + } + else if (_stricmp(String,"No") == 0) + { + Value = false; + } + else if (_stricmp(String,"default") == 0) + { + LoadDefault(Index,Value); + return false; + } + else + { + WriteTraceF(TraceError,__FUNCTION__ ": Invalid Yes/No setting value (Section: %s Key: %s Value: %s)",m_SectionIdent->c_str(),String,m_KeyName.c_str(),strValue.c_str()); + LoadDefault(Index,Value); + return false; + } + + return true; } -bool CSettingTypeRDBYesNo::Load ( int /*Index*/, ULONG & /*Value*/ ) const +bool CSettingTypeRDBYesNo::Load ( int /*Index*/, uint32_t & /*Value*/ ) const { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; } bool CSettingTypeRDBYesNo::Load ( int /*Index*/, stdstr & /*Value*/ ) const { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; } //return the default values void CSettingTypeRDBYesNo::LoadDefault ( int /*Index*/, bool & Value ) const { - if (m_DefaultSetting != Default_None) - { - if (m_DefaultSetting == Default_Constant) - { - Value = m_DefaultValue != 0; - } else { - g_Settings->LoadBool(m_DefaultSetting,Value); - } - } + if (m_DefaultSetting != Default_None) + { + if (m_DefaultSetting == Default_Constant) + { + Value = m_DefaultValue != 0; + } else { + g_Settings->LoadBool(m_DefaultSetting,Value); + } + } } -void CSettingTypeRDBYesNo::LoadDefault ( int /*Index*/, ULONG & /*Value*/ ) const +void CSettingTypeRDBYesNo::LoadDefault ( int /*Index*/, uint32_t & /*Value*/ ) const { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } void CSettingTypeRDBYesNo::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) const { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } - //Update the settings void CSettingTypeRDBYesNo::Save ( int /*Index*/, bool Value ) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "Yes" : "No"); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "Yes" : "No"); } -void CSettingTypeRDBYesNo::Save ( int /*Index*/, ULONG Value ) +void CSettingTypeRDBYesNo::Save ( int /*Index*/, uint32_t Value ) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "Yes" : "No"); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "Yes" : "No"); } void CSettingTypeRDBYesNo::Save ( int /*Index*/, const stdstr & /*Value*/ ) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } void CSettingTypeRDBYesNo::Save ( int /*Index*/, const char * /*Value*/ ) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); } void CSettingTypeRDBYesNo::Delete( int /*Index*/ ) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),NULL); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),NULL); } diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h index 65b8e8607..6331504b0 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h @@ -11,31 +11,34 @@ #pragma once class CSettingTypeRDBYesNo : - public CSettingTypeRomDatabase + public CSettingTypeRomDatabase { - public: - CSettingTypeRDBYesNo(LPCSTR Name, SettingID DefaultSetting ); - CSettingTypeRDBYesNo(LPCSTR Name, int DefaultValue ); - ~CSettingTypeRDBYesNo(); + CSettingTypeRDBYesNo(const char * Name, SettingID DefaultSetting ); + CSettingTypeRDBYesNo(const char * Name, int DefaultValue ); + ~CSettingTypeRDBYesNo(); - //return the values - virtual bool Load ( int Index, bool & Value ) const; - virtual bool Load ( int Index, ULONG & Value ) const; - virtual bool Load ( int Index, stdstr & Value ) const; + //return the values + virtual bool Load ( int Index, bool & Value ) const; + virtual bool Load ( int Index, uint32_t & Value ) const; + virtual bool Load ( int Index, stdstr & Value ) const; - //return the default values - virtual void LoadDefault ( int Index, bool & Value ) const; - virtual void LoadDefault ( int Index, ULONG & Value ) const; - virtual void LoadDefault ( int Index, stdstr & Value ) const; + //return the default values + virtual void LoadDefault ( int Index, bool & Value ) const; + virtual void LoadDefault ( int Index, uint32_t & Value ) const; + virtual void LoadDefault ( int Index, stdstr & Value ) const; - //Update the settings - virtual void Save ( int Index, bool Value ); - virtual void Save ( int Index, ULONG Value ); - virtual void Save ( int Index, const stdstr & Value ); - virtual void Save ( int Index, const char * Value ); + //Update the settings + virtual void Save ( int Index, bool Value ); + virtual void Save ( int Index, uint32_t Value ); + virtual void Save ( int Index, const stdstr & Value ); + virtual void Save ( int Index, const char * Value ); - // Delete the setting - virtual void Delete ( int Index ); + // Delete the setting + virtual void Delete ( int Index ); + +private: + CSettingTypeRDBYesNo(void); // Disable default constructor + CSettingTypeRDBYesNo(const CSettingTypeRDBYesNo&); // Disable copy constructor + CSettingTypeRDBYesNo& operator=(const CSettingTypeRDBYesNo&); // Disable assignment }; - diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp index 7f77fed6d..0c45ae4f3 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp @@ -11,7 +11,7 @@ #include "stdafx.h" #include "SettingsType-RomDatabaseSetting.h" -CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, int DefaultValue, bool DeleteOnDefault ) : +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, int DefaultValue, bool DeleteOnDefault ) : CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault), m_SectionIdent(SectionIdent) { @@ -23,7 +23,7 @@ CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIde } } -CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, bool DefaultValue, bool DeleteOnDefault ) : +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, bool DefaultValue, bool DeleteOnDefault ) : CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault), m_SectionIdent(SectionIdent) { @@ -35,7 +35,7 @@ CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIde } } -CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, LPCSTR DefaultValue, bool DeleteOnDefault ) : +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, const char * DefaultValue, bool DeleteOnDefault ) : CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault), m_SectionIdent(SectionIdent) { @@ -47,7 +47,7 @@ CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIde } } -CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, SettingID DefaultSetting, bool DeleteOnDefault ) : +CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, SettingID DefaultSetting, bool DeleteOnDefault ) : CSettingTypeRomDatabase(Name, DefaultSetting, DeleteOnDefault), m_SectionIdent(SectionIdent) { diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h index 92d00e56a..49db4fd06 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h @@ -13,21 +13,25 @@ #include "SettingsType-RomDatabase.h" class CSettingTypeRomDatabaseSetting : - public CSettingTypeRomDatabase + public CSettingTypeRomDatabase { public: - CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, LPCSTR DefaultValue, bool DeleteOnDefault = false ); - CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, bool DefaultValue, bool DeleteOnDefault = false ); - CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, int DefaultValue, bool DeleteOnDefault = false ); - CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, SettingID DefaultSetting, bool DeleteOnDefault = false ); - - virtual ~CSettingTypeRomDatabaseSetting(); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, const char * DefaultValue, bool DeleteOnDefault = false ); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, bool DefaultValue, bool DeleteOnDefault = false ); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, int DefaultValue, bool DeleteOnDefault = false ); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false ); - virtual SettingType GetSettingType ( void ) const { return SettingType_RdbSetting; } + virtual ~CSettingTypeRomDatabaseSetting(); + + virtual SettingType GetSettingType ( void ) const { return SettingType_RdbSetting; } private: - virtual LPCSTR Section ( void ) const { return m_SectionIdent.c_str(); } + virtual const char * Section ( void ) const { return m_SectionIdent.c_str(); } - stdstr m_SectionIdent; + stdstr m_SectionIdent; + +private: + CSettingTypeRomDatabaseSetting(void); // Disable default constructor + CSettingTypeRomDatabaseSetting(const CSettingTypeRomDatabaseSetting&); // Disable copy constructor + CSettingTypeRomDatabaseSetting& operator=(const CSettingTypeRomDatabaseSetting&); // Disable assignment }; - diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomSetting.h b/Source/Project64/Settings/SettingType/SettingsType-RomSetting.h index 3183094a8..56e11a0c8 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomSetting.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RomSetting.h @@ -1,38 +1,41 @@ #pragma once class CSettingTypeRomDatabase : - public CSettingType + public CSettingType { - - const LPCSTR m_KeyName; - const LPCSTR m_DefaultStr; - const int m_DefaultValue; - const SettingID m_DefaultSetting; - - static CIniFile * m_SettingsIniFile; - static bool m_UseRegistry; - stdstr m_SectionIdent; - public: - CSettingTypeRomDatabase(LPCSTR Name, LPCSTR DefaultValue ); - CSettingTypeRomDatabase(LPCSTR Name, bool DefaultValue ); - CSettingTypeRomDatabase(LPCSTR Name, int DefaultValue ); - CSettingTypeRomDatabase(LPCSTR Name, SettingID DefaultSetting ); - ~CSettingTypeRomDatabase(); + CSettingTypeRomDatabase(const char * Name, const char * DefaultValue ); + CSettingTypeRomDatabase(const char * Name, bool DefaultValue ); + CSettingTypeRomDatabase(const char * Name, int DefaultValue ); + CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting ); + ~CSettingTypeRomDatabase(); - virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; } + virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; } - //return the values - virtual bool Load ( int Index, bool & Value ) const; - virtual bool Load ( int Index, ULONG & Value ) const; - virtual bool Load ( int Index, stdstr & Value ) const; + //return the values + virtual bool Load ( int Index, bool & Value ) const; + virtual bool Load ( int Index, uint32_t & Value ) const; + virtual bool Load ( int Index, stdstr & Value ) const; - //Update the settings - virtual void Save ( int Index, bool Value ); - virtual void Save ( int Index, ULONG Value ); - virtual void Save ( int Index, const stdstr & Value ); - virtual void Save ( int Index, const char * Value ); + //Update the settings + virtual void Save ( int Index, bool Value ); + virtual void Save ( int Index, uint32_t Value ); + virtual void Save ( int Index, const stdstr & Value ); + virtual void Save ( int Index, const char * Value ); - static void Initilize ( void ); + static void Initilize ( void ); + +private: + CSettingTypeRomDatabase(void); // Disable default constructor + CSettingTypeRomDatabase(const CSettingTypeRomDatabase&); // Disable copy constructor + CSettingTypeRomDatabase& operator=(const CSettingTypeRomDatabase&); // Disable assignment + + const const char * m_KeyName; + const const char * m_DefaultStr; + const int m_DefaultValue; + const SettingID m_DefaultSetting; + + static CIniFile * m_SettingsIniFile; + static bool m_UseRegistry; + stdstr m_SectionIdent; }; - diff --git a/Source/Project64/main.cpp b/Source/Project64/main.cpp index 0bb6f61dd..8a23bc025 100644 --- a/Source/Project64/main.cpp +++ b/Source/Project64/main.cpp @@ -5,177 +5,174 @@ CTraceFileLog * LogFile = NULL; void LogLevelChanged (CTraceFileLog * LogFile) { - LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel)); + LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel)); } void LogFlushChanged (CTraceFileLog * LogFile) { - LogFile->SetFlushFile(g_Settings->LoadDword(Debugger_AppLogFlush) != 0); + LogFile->SetFlushFile(g_Settings->LoadDword(Debugger_AppLogFlush) != 0); } - -void InitializeLog ( void) +void InitializeLog ( void) { - CPath LogFilePath(CPath::MODULE_DIRECTORY); - LogFilePath.AppendDirectory("Logs"); - if (!LogFilePath.DirectoryExists()) - { - LogFilePath.CreateDirectory(); - } - LogFilePath.SetNameExtension("Project64.log"); + CPath LogFilePath(CPath::MODULE_DIRECTORY); + LogFilePath.AppendDirectory("Logs"); + if (!LogFilePath.DirectoryExists()) + { + LogFilePath.DirectoryCreate(); + } + LogFilePath.SetNameExtension("Project64.log"); - LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New,500); + LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New,500); #ifdef VALIDATE_DEBUG - LogFile->SetTraceLevel((TraceLevel)(g_Settings->LoadDword(Debugger_AppLogLevel) | TraceValidate | TraceDebug)); + LogFile->SetTraceLevel((TraceLevel)(g_Settings->LoadDword(Debugger_AppLogLevel) | TraceValidate | TraceDebug)); #else - LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel)); + LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel)); #endif - AddTraceModule(LogFile); - - g_Settings->RegisterChangeCB(Debugger_AppLogLevel,LogFile,(CSettings::SettingChangedFunc)LogLevelChanged); - g_Settings->RegisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged); -} + AddTraceModule(LogFile); + g_Settings->RegisterChangeCB(Debugger_AppLogLevel,LogFile,(CSettings::SettingChangedFunc)LogLevelChanged); + g_Settings->RegisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged); +} /*bool ChangeDirPermission ( const CPath & Dir) { - if (Dir.DirectoryExists()) - { - HANDLE hDir = CreateFile(Dir,READ_CONTROL|WRITE_DAC,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL); - if (hDir != INVALID_HANDLE_VALUE) - { - ACL * pOldDACL = NULL; - PSECURITY_DESCRIPTOR pSD = NULL; +if (Dir.DirectoryExists()) +{ +HANDLE hDir = CreateFile(Dir,READ_CONTROL|WRITE_DAC,0,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL); +if (hDir != INVALID_HANDLE_VALUE) +{ +ACL * pOldDACL = NULL; +PSECURITY_DESCRIPTOR pSD = NULL; - if (GetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,&pOldDACL,NULL,&pSD) == ERROR_SUCCESS) - { - bool bAdd = true; +if (GetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,&pOldDACL,NULL,&pSD) == ERROR_SUCCESS) +{ +bool bAdd = true; - PEXPLICIT_ACCESS_W pListOfExplictEntries; - ULONG cCountOfExplicitEntries; - if (GetExplicitEntriesFromAclW(pOldDACL,&cCountOfExplicitEntries,&pListOfExplictEntries) == ERROR_SUCCESS) - { - for (int i = 0; i < cCountOfExplicitEntries; i ++) - { - EXPLICIT_ACCESS_W &ea = pListOfExplictEntries[i]; - if (ea.grfAccessMode != GRANT_ACCESS) { continue; } - if (ea.grfAccessPermissions != GENERIC_ALL) { continue; } - if ((ea.grfInheritance & (CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE)) != (CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE)) { continue; } +PEXPLICIT_ACCESS_W pListOfExplictEntries; +ULONG cCountOfExplicitEntries; +if (GetExplicitEntriesFromAclW(pOldDACL,&cCountOfExplicitEntries,&pListOfExplictEntries) == ERROR_SUCCESS) +{ +for (int i = 0; i < cCountOfExplicitEntries; i ++) +{ +EXPLICIT_ACCESS_W &ea = pListOfExplictEntries[i]; +if (ea.grfAccessMode != GRANT_ACCESS) { continue; } +if (ea.grfAccessPermissions != GENERIC_ALL) { continue; } +if ((ea.grfInheritance & (CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE)) != (CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE)) { continue; } - if (ea.Trustee.TrusteeType == TRUSTEE_IS_SID) - { - - } - bAdd = false; - } - } +if (ea.Trustee.TrusteeType == TRUSTEE_IS_SID) +{ +} +bAdd = false; +} +} - if (bAdd) - { - EXPLICIT_ACCESS ea = {0}; - ea.grfAccessMode = GRANT_ACCESS; - ea.grfAccessPermissions = GENERIC_ALL; - ea.grfInheritance = CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE; - ea.Trustee.TrusteeType = TRUSTEE_IS_GROUP; - ea.Trustee.TrusteeForm = TRUSTEE_IS_NAME; - ea.Trustee.ptstrName = TEXT("Users"); +if (bAdd) +{ +EXPLICIT_ACCESS ea = {0}; +ea.grfAccessMode = GRANT_ACCESS; +ea.grfAccessPermissions = GENERIC_ALL; +ea.grfInheritance = CONTAINER_INHERIT_ACE|OBJECT_INHERIT_ACE; +ea.Trustee.TrusteeType = TRUSTEE_IS_GROUP; +ea.Trustee.TrusteeForm = TRUSTEE_IS_NAME; +ea.Trustee.ptstrName = TEXT("Users"); - ACL * pNewDACL = NULL; - SetEntriesInAcl(1,&ea,pOldDACL,&pNewDACL); +ACL * pNewDACL = NULL; +SetEntriesInAcl(1,&ea,pOldDACL,&pNewDACL); - SetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,pNewDACL,NULL); - LocalFree(pNewDACL); - } - LocalFree(pSD); - } - CloseHandle(hDir); - } - } - return true; +SetSecurityInfo(hDir,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,pNewDACL,NULL); +LocalFree(pNewDACL); +} +LocalFree(pSD); +} +CloseHandle(hDir); +} +} +return true; }*/ void FixDirectories ( void ) { CPath Directory(CPath::MODULE_DIRECTORY); Directory.AppendDirectory("Config"); - if (!Directory.DirectoryExists()) Directory.CreateDirectory(); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); Directory.UpDirectory(); Directory.AppendDirectory("Logs"); - if (!Directory.DirectoryExists()) Directory.CreateDirectory(); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); Directory.UpDirectory(); Directory.AppendDirectory("Save"); - if (!Directory.DirectoryExists()) Directory.CreateDirectory(); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); Directory.UpDirectory(); Directory.AppendDirectory("Screenshots"); - if (!Directory.DirectoryExists()) Directory.CreateDirectory(); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); Directory.UpDirectory(); Directory.AppendDirectory("textures"); - if (!Directory.DirectoryExists()) Directory.CreateDirectory(); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); } bool TerminatedExistingEmu() { - bool bTerminated = false; - bool AskedUser = false; - DWORD pid = GetCurrentProcessId(); + bool bTerminated = false; + bool AskedUser = false; + DWORD pid = GetCurrentProcessId(); - HANDLE nSearch = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if(nSearch != INVALID_HANDLE_VALUE) - { - PROCESSENTRY32 lppe; + HANDLE nSearch = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if(nSearch != INVALID_HANDLE_VALUE) + { + PROCESSENTRY32 lppe; - memset(&lppe, 0, sizeof(PROCESSENTRY32)); - lppe.dwSize = sizeof(PROCESSENTRY32); - stdstr ModuleName = CPath(CPath::MODULE_FILE).GetNameExtension(); + memset(&lppe, 0, sizeof(PROCESSENTRY32)); + lppe.dwSize = sizeof(PROCESSENTRY32); + stdstr ModuleName = CPath(CPath::MODULE_FILE).GetNameExtension(); - if (Process32First(nSearch, &lppe)) - { - do - { - if(_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 || - lppe.th32ProcessID == pid) - { - continue; - } - if (!AskedUser) - { - AskedUser = true; - int res = MessageBox(NULL,stdstr_f("Project64.exe currently running\n\nTerminate pid %d now?",lppe.th32ProcessID).c_str(),"Terminate project64",MB_YESNO|MB_ICONEXCLAMATION); - if (res != IDYES) - { - break; - } - } - HANDLE hHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, lppe.th32ProcessID); - if(hHandle != NULL) - { - if (TerminateProcess(hHandle, 0)) - { - bTerminated = true; - } else { - MessageBox(NULL,stdstr_f("Failed to terminate pid %d",lppe.th32ProcessID).c_str(),"Terminate project64 failed!",MB_YESNO|MB_ICONEXCLAMATION); - } - CloseHandle(hHandle); - } - } while (Process32Next(nSearch, &lppe)); - } - CloseHandle(nSearch); - } - return bTerminated; + if (Process32First(nSearch, &lppe)) + { + do + { + if(_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 || + lppe.th32ProcessID == pid) + { + continue; + } + if (!AskedUser) + { + AskedUser = true; + int res = MessageBox(NULL,stdstr_f("Project64.exe currently running\n\nTerminate pid %d now?",lppe.th32ProcessID).c_str(),"Terminate project64",MB_YESNO|MB_ICONEXCLAMATION); + if (res != IDYES) + { + break; + } + } + HANDLE hHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, lppe.th32ProcessID); + if(hHandle != NULL) + { + if (TerminateProcess(hHandle, 0)) + { + bTerminated = true; + } else { + MessageBox(NULL,stdstr_f("Failed to terminate pid %d",lppe.th32ProcessID).c_str(),"Terminate project64 failed!",MB_YESNO|MB_ICONEXCLAMATION); + } + CloseHandle(hHandle); + } + } while (Process32Next(nSearch, &lppe)); + } + CloseHandle(nSearch); + } + return bTerminated; } -const char * AppName ( void ) +const char * AppName ( void ) { - static stdstr Name; - if (Name.empty()) - { - Name = stdstr_f("Project64 %s", VER_FILE_VERSION_STR); - } - return Name.c_str(); + static stdstr Name; + if (Name.empty()) + { + Name = stdstr_f("Project64 %s", VER_FILE_VERSION_STR); + } + return Name.c_str(); } #ifndef WINDOWS_UI @@ -204,8 +201,8 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / delete lbuffer; CoInitialize(NULL); - try - { + try + { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL ); g_Lang = new CLanguage(); @@ -234,59 +231,59 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / //Select the language g_Lang->LoadCurrentStrings(true); - //Create the main window with Menu - WriteTrace(TraceDebug,__FUNCTION__ ": Create Main Window"); + //Create the main window with Menu + WriteTrace(TraceDebug,__FUNCTION__ ": Create Main Window"); stdstr WinTitle(AppName()); WinTitle.Format("Project64 %s", VER_FILE_VERSION_STR); CMainGui MainWindow(true,WinTitle.c_str()), HiddenWindow(false); - CMainMenu MainMenu(&MainWindow); - g_Plugins->SetRenderWindows(&MainWindow,&HiddenWindow); - g_Notify->SetMainWindow(&MainWindow); + CMainMenu MainMenu(&MainWindow); + g_Plugins->SetRenderWindows(&MainWindow,&HiddenWindow); + Notify().SetMainWindow(&MainWindow); - if (__argc > 1) - { - WriteTraceF(TraceDebug,__FUNCTION__ ": Cmd line found \"%s\"",__argv[1]); - MainWindow.Show(true); //Show the main window - CN64System::RunFileImage(__argv[1]); - } - else - { - if (g_Settings->LoadDword(RomBrowser_Enabled)) - { - WriteTrace(TraceDebug,__FUNCTION__ ": Show Rom Browser"); - //Display the rom browser - MainWindow.ShowRomList(); - MainWindow.Show(true); //Show the main window - MainWindow.HighLightLastRom(); - } else { - WriteTrace(TraceDebug,__FUNCTION__ ": Show Main Window"); - MainWindow.Show(true); //Show the main window - } - } - - //Process Messages till program is closed - WriteTrace(TraceDebug,__FUNCTION__ ": Entering Message Loop"); - MainWindow.ProcessAllMessages(); - WriteTrace(TraceDebug,__FUNCTION__ ": Message Loop Finished"); + if (__argc > 1) + { + WriteTraceF(TraceDebug,__FUNCTION__ ": Cmd line found \"%s\"",__argv[1]); + MainWindow.Show(true); //Show the main window + CN64System::RunFileImage(__argv[1]); + } + else + { + if (g_Settings->LoadDword(RomBrowser_Enabled)) + { + WriteTrace(TraceDebug,__FUNCTION__ ": Show Rom Browser"); + //Display the rom browser + MainWindow.ShowRomList(); + MainWindow.Show(true); //Show the main window + MainWindow.HighLightLastRom(); + } else { + WriteTrace(TraceDebug,__FUNCTION__ ": Show Main Window"); + MainWindow.Show(true); //Show the main window + } + } - if (g_BaseSystem) - { - g_BaseSystem->CloseCpu(); - delete g_BaseSystem; - g_BaseSystem = NULL; - } - WriteTrace(TraceDebug,__FUNCTION__ ": System Closed"); - - g_Settings->UnregisterChangeCB(Debugger_AppLogLevel,LogFile,(CSettings::SettingChangedFunc)LogLevelChanged); - g_Settings->UnregisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged); - } - catch(...) - { - WriteTraceF(TraceError,__FUNCTION__ ": Exception caught (File: \"%s\" Line: %d)",__FILE__,__LINE__); - MessageBox(NULL,stdstr_f("Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__).c_str(),"Exception",MB_OK); - } + //Process Messages till program is closed + WriteTrace(TraceDebug,__FUNCTION__ ": Entering Message Loop"); + MainWindow.ProcessAllMessages(); + WriteTrace(TraceDebug,__FUNCTION__ ": Message Loop Finished"); + + if (g_BaseSystem) + { + g_BaseSystem->CloseCpu(); + delete g_BaseSystem; + g_BaseSystem = NULL; + } + WriteTrace(TraceDebug,__FUNCTION__ ": System Closed"); + + g_Settings->UnregisterChangeCB(Debugger_AppLogLevel,LogFile,(CSettings::SettingChangedFunc)LogLevelChanged); + g_Settings->UnregisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged); + } + catch(...) + { + WriteTraceF(TraceError,__FUNCTION__ ": Exception caught (File: \"%s\" Line: %d)",__FILE__,__LINE__); + MessageBox(NULL,stdstr_f("Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__).c_str(),"Exception",MB_OK); + } WriteTrace(TraceDebug,__FUNCTION__ ": cleaning up global objects"); if (g_Rom) { delete g_Rom; g_Rom = NULL; } @@ -299,6 +296,6 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / CoUninitialize(); WriteTrace(TraceDebug,__FUNCTION__ ": Done"); CloseTrace(); - return true; + return true; } #endif