[Project64] Clean up path code

This commit is contained in:
zilmar 2015-10-25 22:10:54 +11:00
parent 81fdcb9373
commit 0144305c6a
26 changed files with 706 additions and 708 deletions

View File

@ -1,5 +1,4 @@
#ifndef __TRACE_H__ #pragma once
#define __TRACE_H__
class CTraceModule class CTraceModule
{ {
@ -46,5 +45,3 @@ public:
CTraceModule * AddTraceModule ( CTraceModule * TraceModule ); // Must be created with new CTraceModule * AddTraceModule ( CTraceModule * TraceModule ); // Must be created with new
CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule ); // Is not automaticly deleted CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule ); // Is not automaticly deleted
#endif // __TRACE_H__

View File

@ -1,5 +1,4 @@
#ifndef __TRACE_DEFS_H__ #pragma once
#define __TRACE_DEFS_H__
enum TraceType enum TraceType
{ {
@ -27,10 +26,6 @@ enum TraceLevel
TrLvAll = ~TraceNoHeader, TrLvAll = ~TraceNoHeader,
}; };
void WriteTrace ( TraceType Type, const char * Message );
void WriteTrace ( TraceType Type, LPCTSTR Message ); void WriteTraceF ( TraceType Type, const char * strFormat, ... );
void WriteTraceF ( TraceType Type, LPCTSTR strFormat, ... );
void CloseTrace ( void ); //Free's all memory associated with trace void CloseTrace ( void ); //Free's all memory associated with trace
#endif // __TRACE_DEFS_H__

View File

@ -3,36 +3,36 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
#include "stdafx.h" #include "stdafx.h"
#include <Shlobj.h> #include <Shlobj.h>
#include <TChar.H> #include <dos.h>
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Constants // Constants
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
LPCTSTR const DLL_EXTENSION = _T("dll"); const char * const DLL_EXTENSION = "dll";
LPCTSTR const INI_EXTENSION = _T("ini"); const char * const INI_EXTENSION = "ini";
LPCTSTR const EXE_EXTENSION = _T("exe"); const char * const EXE_EXTENSION = "exe";
LPCTSTR const WILD_NAME_EXTENSION = _T("*.*"); const char * const WILD_NAME_EXTENSION = "*.*";
const TCHAR WILD_ONE = '?'; const TCHAR WILD_ONE = '?';
const TCHAR WILD_ANY = '*'; const TCHAR WILD_ANY = '*';
LPCTSTR const WILD_SET = _T("?*"); const char * const WILD_SET = "?*";
LPCTSTR const DIR_DOUBLEDELIM = _T("\\\\"); const char * const DIR_DOUBLEDELIM = "\\\\";
const TCHAR DRIVE_DELIMITER = ':'; const TCHAR DRIVE_DELIMITER = ':';
const TCHAR DIRECTORY_DELIMITER = '\\'; const TCHAR DIRECTORY_DELIMITER = '\\';
const TCHAR EXTENSION_DELIMITER = '.'; const TCHAR EXTENSION_DELIMITER = '.';
const TCHAR DIRECTORY_DELIMITER2 = '/'; const TCHAR DIRECTORY_DELIMITER2 = '/';
HINSTANCE CPath::m_hInst = NULL; void * CPath::m_hInst = NULL;
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Helpers // Helpers
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
void CPath::SethInst ( HINSTANCE hInst ) void CPath::SethInst ( void * hInst )
{ {
m_hInst = hInst; m_hInst = hInst;
} }
HINSTANCE CPath::GethInst() void * CPath::GethInst()
{ {
return m_hInst; return m_hInst;
} }
@ -90,14 +90,14 @@ CPath::CPath(const CPath& rPath)
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Constructs a path and points it 2 lpszPath // Task : Constructs a path and points it 2 lpszPath
//------------------------------------------------------------- //-------------------------------------------------------------
CPath::CPath(LPCTSTR lpszPath) CPath::CPath(const char * lpszPath)
{ {
Init(); Init();
m_strPath =lpszPath ? lpszPath : _T(""); m_strPath =lpszPath ? lpszPath : "";
cleanPathString(m_strPath); cleanPathString(m_strPath);
} }
CPath::CPath(LPCTSTR lpszPath, LPCTSTR NameExten) CPath::CPath(const char * lpszPath, const char * NameExten)
{ {
Init(); Init();
SetDriveDirectory(lpszPath); SetDriveDirectory(lpszPath);
@ -107,7 +107,7 @@ CPath::CPath(LPCTSTR lpszPath, LPCTSTR NameExten)
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Constructs a path and points it 2 strPath // Task : Constructs a path and points it 2 strPath
//------------------------------------------------------------- //-------------------------------------------------------------
CPath::CPath(const stdstr& strPath) CPath::CPath(const std::string& strPath)
{ {
Init(); Init();
m_strPath =strPath; m_strPath =strPath;
@ -117,7 +117,7 @@ CPath::CPath(const stdstr& strPath)
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Constructs a path and points it 2 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(); Init();
SetDriveDirectory(strPath.c_str()); SetDriveDirectory(strPath.c_str());
@ -127,7 +127,7 @@ CPath::CPath(const stdstr& strPath, LPCTSTR NameExten )
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Constructs a path and points it 2 strPath // 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(); Init();
SetDriveDirectory(strPath.c_str()); SetDriveDirectory(strPath.c_str());
@ -147,24 +147,24 @@ CPath::~CPath()
// Post : Return TRUE if paths are equal // Post : Return TRUE if paths are equal
// Task : Check if the two path are the same // 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 // Get fully qualified versions of the paths
stdstr FullyQualified1; std::string FullyQualified1;
stdstr FullyQualified2; std::string FullyQualified2;
GetFullyQualified(FullyQualified1); GetFullyQualified(FullyQualified1);
rPath.GetFullyQualified(FullyQualified2); rPath.GetFullyQualified(FullyQualified2);
// Compare them // 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 // Post : Return TRUE if paths are different
// Task : Check if the two path 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); return !(*this == rPath);
} }
@ -183,9 +183,9 @@ CPath& CPath::operator =(const CPath& rPath)
// Post : Return the path, so that assignements can be chained // Post : Return the path, so that assignements can be chained
// Task : Assign a string 2 a path // 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; return *this;
} }
@ -193,7 +193,7 @@ CPath& CPath::operator =(LPCTSTR lpszPath)
// Post : Return the path, so that assignements can be chained // Post : Return the path, so that assignements can be chained
// Task : Assign a string 2 a path // Task : Assign a string 2 a path
//------------------------------------------------------------- //-------------------------------------------------------------
CPath& CPath::operator =(const stdstr& strPath) CPath& CPath::operator =(const std::string& strPath)
{ {
m_strPath =strPath; m_strPath =strPath;
return *this; return *this;
@ -207,12 +207,12 @@ CPath& CPath::operator =(const stdstr& strPath)
// function in any non-constant pointer and alter the data. // function in any non-constant pointer and alter the data.
// Very dangerous // 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 // Application's current directory
Init(); Init();
@ -220,7 +220,7 @@ CPath::CPath(DIR_CURRENT_DIRECTORY /*sdt*/, LPCTSTR NameExten)
if (NameExten) { SetNameExtension(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 // The directory where the executable of this app is
Init(); Init();
@ -249,10 +249,10 @@ CPath::CPath(DIR_MODULE_FILE /*sdt*/)
// Do not rely on pNames being <= 8 characters, extensions // Do not rely on pNames being <= 8 characters, extensions
// being <= 3 characters, or drives being 1 character // being <= 3 characters, or drives being 1 character
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetComponents(stdstr* pDrive, void CPath::GetComponents(std::string* pDrive,
stdstr* pDirectory, std::string* pDirectory,
stdstr* pName, std::string* pName,
stdstr* pExtension) const std::string* pExtension) const
{ {
TCHAR buff_drive[_MAX_DRIVE + 1]; TCHAR buff_drive[_MAX_DRIVE + 1];
TCHAR buff_dir [_MAX_DIR + 1]; TCHAR buff_dir [_MAX_DIR + 1];
@ -264,7 +264,7 @@ void CPath::GetComponents(stdstr* pDrive,
ZeroMemory(buff_name, sizeof(buff_name)); ZeroMemory(buff_name, sizeof(buff_name));
ZeroMemory(buff_ext, sizeof(buff_ext)); ZeroMemory(buff_ext, sizeof(buff_ext));
_tsplitpath(m_strPath.c_str(), _splitpath(m_strPath.c_str(),
pDrive ? buff_drive : NULL, pDrive ? buff_drive : NULL,
pDirectory ? buff_dir : NULL, pDirectory ? buff_dir : NULL,
pName ? buff_name : NULL, pName ? buff_name : NULL,
@ -293,10 +293,10 @@ void CPath::GetComponents(stdstr* pDrive,
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Get drive and directory from path // Task : Get drive and directory from path
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetDriveDirectory(stdstr& rDriveDirectory) const void CPath::GetDriveDirectory(std::string& rDriveDirectory) const
{ {
stdstr Drive; std::string Drive;
stdstr Directory; std::string Directory;
GetComponents(&Drive,&Directory); GetComponents(&Drive,&Directory);
rDriveDirectory =Drive; 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); GetDriveDirectory(rDriveDirectory);
return rDriveDirectory; return rDriveDirectory;
} }
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Get directory from path // Task : Get directory from path
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetDirectory(stdstr& rDirectory) const void CPath::GetDirectory(std::string& rDirectory) const
{ {
GetComponents(NULL,&rDirectory); GetComponents(NULL,&rDirectory);
} }
stdstr CPath::GetDirectory(void) const std::string CPath::GetDirectory(void) const
{ {
stdstr rDirectory; std::string rDirectory;
GetComponents(NULL,&rDirectory); GetComponents(NULL,&rDirectory);
return rDirectory; return rDirectory;
} }
@ -331,10 +331,10 @@ stdstr CPath::GetDirectory(void) const
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Get filename and extension from path // Task : Get filename and extension from path
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetNameExtension(stdstr& rNameExtension) const void CPath::GetNameExtension(std::string& rNameExtension) const
{ {
stdstr Name; std::string Name;
stdstr Extension; std::string Extension;
GetComponents(NULL,NULL,&Name,&Extension); GetComponents(NULL,NULL,&Name,&Extension);
rNameExtension =Name; 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); GetNameExtension(rNameExtension);
return rNameExtension; return rNameExtension;
} }
@ -355,14 +355,14 @@ stdstr CPath::GetNameExtension(void) const
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Get filename from path // Task : Get filename from path
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetName(stdstr& rName) const void CPath::GetName(std::string& rName) const
{ {
GetComponents(NULL,NULL,&rName); GetComponents(NULL,NULL,&rName);
} }
stdstr CPath::GetName(void) const std::string CPath::GetName(void) const
{ {
stdstr rName; std::string rName;
GetComponents(NULL,NULL,&rName); GetComponents(NULL,NULL,&rName);
return rName; return rName;
} }
@ -370,14 +370,14 @@ stdstr CPath::GetName(void) const
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Get file extension from path // Task : Get file extension from path
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetExtension(stdstr& rExtension) const void CPath::GetExtension(std::string& rExtension) const
{ {
GetComponents(NULL,NULL,NULL,&rExtension); 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); GetComponents(NULL,NULL,NULL,&rExtension);
return rExtension; return rExtension;
} }
@ -385,9 +385,9 @@ stdstr CPath::GetExtension(void) const
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Get current directory // Task : Get current directory
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetCurrentDirectory(stdstr& rDirectory) const void CPath::GetCurrentDirectory(std::string& rDirectory) const
{ {
stdstr Directory; std::string Directory;
rDirectory = ""; rDirectory = "";
@ -396,15 +396,15 @@ void CPath::GetCurrentDirectory(stdstr& rDirectory) const
if(Directory.empty()) if(Directory.empty())
return; return;
stdstr::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER); std::string::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER);
rDirectory =Directory.substr(nDelimiter); rDirectory =Directory.substr(nDelimiter);
StripLeadingBackslash(rDirectory); StripLeadingBackslash(rDirectory);
} }
stdstr CPath::GetCurrentDirectory(void) const std::string CPath::GetCurrentDirectory(void) const
{ {
stdstr rDirecotry; std::string rDirecotry;
GetCurrentDirectory(rDirecotry); GetCurrentDirectory(rDirecotry);
return rDirecotry; return rDirecotry;
} }
@ -412,13 +412,13 @@ stdstr CPath::GetCurrentDirectory(void) const
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Get fully qualified path // Task : Get fully qualified path
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::GetFullyQualified(stdstr& rFullyQualified) const void CPath::GetFullyQualified(std::string& rFullyQualified) const
{ {
TCHAR buff_fullname[MAX_PATH]; TCHAR buff_fullname[MAX_PATH];
memset(buff_fullname, 0, sizeof(buff_fullname)); 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; rFullyQualified =buff_fullname;
} }
@ -426,7 +426,7 @@ void CPath::GetFullyQualified(stdstr& rFullyQualified) const
// Post : Return TRUE if path does not start from filesystem root // 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:\...) // 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) if (m_strPath.length() > 1 && m_strPath[1] == DRIVE_DELIMITER)
{ {
@ -442,16 +442,16 @@ BOOL CPath::IsRelative() const
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Set path components // Task : Set path components
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::SetComponents(LPCTSTR lpszDrive, void CPath::SetComponents(const char * lpszDrive,
LPCTSTR lpszDirectory, const char * lpszDirectory,
LPCTSTR lpszName, const char * lpszName,
LPCTSTR lpszExtension) const char * lpszExtension)
{ {
TCHAR buff_fullname[MAX_PATH]; TCHAR buff_fullname[MAX_PATH];
memset(buff_fullname, 0, sizeof(buff_fullname)); 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.erase();
m_strPath =buff_fullname; m_strPath =buff_fullname;
@ -462,10 +462,10 @@ void CPath::SetComponents(LPCTSTR lpszDrive,
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::SetDrive(TCHAR chDrive) void CPath::SetDrive(TCHAR chDrive)
{ {
stdstr_f Drive(_T("%c"),chDrive); stdstr_f Drive("%c",chDrive);
stdstr Directory; std::string Directory;
stdstr Name; std::string Name;
stdstr Extension; std::string Extension;
GetComponents(NULL,&Directory,&Name,&Extension); GetComponents(NULL,&Directory,&Name,&Extension);
SetComponents(Drive.c_str(),Directory.c_str(),Name.c_str(),Extension.c_str()); 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 // Task : Set path's directory
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::SetDirectory(LPCTSTR lpszDirectory, BOOL bEnsureAbsolute /*= FALSE*/) void CPath::SetDirectory(const char * lpszDirectory, bool bEnsureAbsolute /*= FALSE*/)
{ {
stdstr Drive; std::string Drive;
stdstr Directory =lpszDirectory; std::string Directory =lpszDirectory;
stdstr Name; std::string Name;
stdstr Extension; std::string Extension;
if(bEnsureAbsolute) if(bEnsureAbsolute)
EnsureLeadingBackslash(Directory); EnsureLeadingBackslash(Directory);
@ -492,11 +492,11 @@ void CPath::SetDirectory(LPCTSTR lpszDirectory, BOOL bEnsureAbsolute /*= FALSE*/
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Set path's drive and directory // Task : Set path's drive and directory
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::SetDriveDirectory(LPCTSTR lpszDriveDirectory) void CPath::SetDriveDirectory(const char * lpszDriveDirectory)
{ {
stdstr DriveDirectory =lpszDriveDirectory; std::string DriveDirectory =lpszDriveDirectory;
stdstr Name; std::string Name;
stdstr Extension; std::string Extension;
EnsureTrailingBackslash(DriveDirectory); EnsureTrailingBackslash(DriveDirectory);
cleanPathString(DriveDirectory); cleanPathString(DriveDirectory);
@ -508,11 +508,11 @@ void CPath::SetDriveDirectory(LPCTSTR lpszDriveDirectory)
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Set path's filename // Task : Set path's filename
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::SetName(LPCTSTR lpszName) void CPath::SetName(const char * lpszName)
{ {
stdstr Drive; std::string Drive;
stdstr Directory; std::string Directory;
stdstr Extension; std::string Extension;
GetComponents(&Drive,&Directory,NULL,&Extension); GetComponents(&Drive,&Directory,NULL,&Extension);
SetComponents(Drive.c_str(),Directory.c_str(),lpszName,Extension.c_str()); 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) void CPath::SetName(int iName)
{ {
stdstr Drive; std::string Drive;
stdstr Directory; std::string Directory;
stdstr Extension; std::string Extension;
TCHAR sName[33]; TCHAR sName[33];
memset(sName, 0, sizeof(sName)); memset(sName, 0, sizeof(sName));
_itot(iName, sName, 10); _itoa(iName, sName, 10);
GetComponents(&Drive,&Directory,NULL,&Extension); GetComponents(&Drive,&Directory,NULL,&Extension);
SetComponents(Drive.c_str(),Directory.c_str(),sName,Extension.c_str()); 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 // Task : Set path's file extension
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::SetExtension(LPCTSTR lpszExtension) void CPath::SetExtension(const char * lpszExtension)
{ {
stdstr Drive; std::string Drive;
stdstr Directory; std::string Directory;
stdstr Name; std::string Name;
GetComponents(&Drive,&Directory,&Name); GetComponents(&Drive,&Directory,&Name);
SetComponents(Drive.c_str(),Directory.c_str(),Name.c_str(),lpszExtension); 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) void CPath::SetExtension(int iExtension)
{ {
stdstr Drive; std::string Drive;
stdstr Directory; std::string Directory;
stdstr Name; std::string Name;
TCHAR sExtension[20]; TCHAR sExtension[20];
memset(sExtension, 0, sizeof(sExtension)); memset(sExtension, 0, sizeof(sExtension));
_itot(iExtension, sExtension, 10); _itoa(iExtension, sExtension, 10);
GetComponents(&Drive,&Directory,&Name); GetComponents(&Drive,&Directory,&Name);
SetComponents(Drive.c_str(),Directory.c_str(),Name.c_str(),sExtension); 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 // Task : Set path's filename and extension
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::SetNameExtension(LPCTSTR lpszNameExtension) void CPath::SetNameExtension(const char * lpszNameExtension)
{ {
stdstr Drive; std::string Drive;
stdstr Directory; std::string Directory;
GetComponents(&Drive,&Directory); GetComponents(&Drive,&Directory);
SetComponents(Drive.c_str(),Directory.c_str(),lpszNameExtension,NULL); 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 // Task : Append a subdirectory 2 path's directory
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::AppendDirectory(LPCTSTR lpszSubDirectory) void CPath::AppendDirectory(const char * lpszSubDirectory)
{ {
stdstr Drive; std::string Drive;
stdstr Directory; std::string Directory;
stdstr SubDirectory =lpszSubDirectory; std::string SubDirectory =lpszSubDirectory;
stdstr Name; std::string Name;
stdstr Extension; std::string Extension;
if(SubDirectory.empty()) if(SubDirectory.empty())
return; return;
@ -610,16 +610,16 @@ void CPath::AppendDirectory(LPCTSTR lpszSubDirectory)
// deepest directory (the one we're just exiting) in it // deepest directory (the one we're just exiting) in it
// Task : Remove deepest subdirectory from path // 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); GetDirectory(Directory);
StripTrailingBackslash(Directory); StripTrailingBackslash(Directory);
if(Directory.empty()) if(Directory.empty())
return; return;
stdstr::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER); std::string::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER);
if(pLastDirectory != NULL) if(pLastDirectory != NULL)
{ {
@ -627,7 +627,7 @@ void CPath::UpDirectory(stdstr *pLastDirectory /*= NULL*/)
StripLeadingBackslash(*pLastDirectory); StripLeadingBackslash(*pLastDirectory);
} }
if(nDelimiter != stdstr::npos) if(nDelimiter != std::string::npos)
Directory =Directory.substr(0,nDelimiter); Directory =Directory.substr(0,nDelimiter);
SetDirectory(Directory.c_str()); SetDirectory(Directory.c_str());
@ -651,13 +651,13 @@ void CPath::CurrentDirectory()
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Set path 2 the name of specified module // Task : Set path 2 the name of specified module
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::Module(HINSTANCE hInstance) void CPath::Module(void * hInstance)
{ {
TCHAR buff_path[MAX_PATH]; TCHAR buff_path[MAX_PATH];
memset(buff_path, 0, sizeof(buff_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; m_strPath =buff_path;
} }
@ -669,17 +669,17 @@ void CPath::Module()
TCHAR buff_path[MAX_PATH]; TCHAR buff_path[MAX_PATH];
memset(buff_path, 0, sizeof(buff_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; m_strPath =buff_path;
} }
//------------------------------------------------------------- //-------------------------------------------------------------
// Task : Set path 2 the directory of specified module // Task : Set path 2 the directory of specified module
//------------------------------------------------------------- //-------------------------------------------------------------
void CPath::ModuleDirectory(HINSTANCE hInstance) void CPath::ModuleDirectory(void * hInstance)
{ {
Module(hInstance); Module((HINSTANCE)hInstance);
SetNameExtension(_T("")); SetNameExtension("");
} }
//------------------------------------------------------------- //-------------------------------------------------------------
@ -688,17 +688,17 @@ void CPath::ModuleDirectory(HINSTANCE hInstance)
void CPath::ModuleDirectory() void CPath::ModuleDirectory()
{ {
Module(); Module();
SetNameExtension(_T("")); SetNameExtension("");
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Post : Return TRUE if a directory // Post : Return TRUE if a directory
// Task : Check if this path represents 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 // Check if this path has a filename
stdstr file_name; std::string file_name;
GetNameExtension(file_name); GetNameExtension(file_name);
return file_name.empty(); return file_name.empty();
@ -712,18 +712,18 @@ BOOL CPath::IsDirectory() const
// use CPath::FindFirst() because that routine parses out // use CPath::FindFirst() because that routine parses out
// '.' and '..', which fails for empty directories // '.' and '..', which fails for empty directories
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::DirectoryExists() const bool CPath::DirectoryExists() const
{ {
// Create test path // Create test path
CPath TestPath(m_strPath.c_str()); CPath TestPath(m_strPath.c_str());
stdstr DirName; std::string DirName;
TestPath.UpDirectory(&DirName); TestPath.UpDirectory(&DirName);
TestPath.SetNameExtension(DirName.c_str()); TestPath.SetNameExtension(DirName.c_str());
WIN32_FIND_DATA FindData; WIN32_FIND_DATA FindData;
HANDLE hFindFile =FindFirstFile((LPCTSTR)TestPath,&FindData); // Find anything HANDLE hFindFile =FindFirstFile((const char *)TestPath,&FindData); // Find anything
BOOL bGotFile =(hFindFile != INVALID_HANDLE_VALUE); bool bGotFile =(hFindFile != INVALID_HANDLE_VALUE);
if(hFindFile != NULL) // Make sure we close the search if(hFindFile != NULL) // Make sure we close the search
FindClose(hFindFile); FindClose(hFindFile);
@ -735,11 +735,11 @@ BOOL CPath::DirectoryExists() const
// Post : Return TRUE if these is such a file // Post : Return TRUE if these is such a file
// Task : Check if file exists // Task : Check if file exists
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::Exists() const bool CPath::Exists() const
{ {
WIN32_FIND_DATA FindData; WIN32_FIND_DATA FindData;
HANDLE hFindFile =FindFirstFile(m_strPath.c_str(),&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 if(hFindFile != NULL) // Make sure we close the search
FindClose(hFindFile); FindClose(hFindFile);
@ -751,10 +751,10 @@ BOOL CPath::Exists() const
// Post : Return TRUE on success // Post : Return TRUE on success
// Task : Delete file // Task : Delete file
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::Delete(BOOL bEvenIfReadOnly) const bool CPath::Delete(bool bEvenIfReadOnly) const
{ {
ULONG dwAttr =::GetFileAttributes(m_strPath.c_str()); uint32_t dwAttr =::GetFileAttributes(m_strPath.c_str());
if(dwAttr == (ULONG)-1) if(dwAttr == (uint32_t)-1)
// File does not exists // File does not exists
return FALSE; return FALSE;
@ -763,7 +763,7 @@ BOOL CPath::Delete(BOOL bEvenIfReadOnly) const
return FALSE; return FALSE;
SetFileAttributes(m_strPath.c_str(),FILE_ATTRIBUTE_NORMAL); 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 // Since ::CopyFile will not overwrite read only files
// we will make sure the target file is writable first // 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 // Check if the target file exists
CPath TargetFile(lpcszTargetFile); 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 // CopyFile will set the target's attributes 2 the same as
// the source after copying // 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 // and we weren't granted permission 2 overwrite file or some error
// Task : Move file // Task : Move file
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::MoveTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite) bool CPath::MoveTo(const char * lpcszTargetFile, bool bOverwrite)
{ {
// Check if the target file exists // Check if the target file exists
CPath TargetFile(lpcszTargetFile); CPath TargetFile(lpcszTargetFile);
@ -815,14 +815,14 @@ BOOL CPath::MoveTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite)
return FALSE; return FALSE;
} }
return MoveFile(m_strPath.c_str(),lpcszTargetFile); return MoveFile(m_strPath.c_str(),lpcszTargetFile) != 0;
} }
//------------------------------------------------------------- //-------------------------------------------------------------
// Post : Return TRUE if attributes do match // Post : Return TRUE if attributes do match
// Task : Compare finder attributes // Task : Compare finder attributes
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::AttributesMatch(ULONG dwTargetAttributes, ULONG dwFileAttributes) bool CPath::AttributesMatch(uint32_t dwTargetAttributes, uint32_t dwFileAttributes)
{ {
if (dwTargetAttributes == _A_ALLFILES) if (dwTargetAttributes == _A_ALLFILES)
{ {
@ -863,7 +863,7 @@ BOOL CPath::AttributesMatch(ULONG dwTargetAttributes, ULONG dwFileAttributes)
// if you specify those attributes // if you specify those attributes
// See aso: FindFirstFile, FindNextFile // See aso: FindFirstFile, FindNextFile
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::FindFirst(ULONG dwAttributes /*= _A_NORMAL*/) bool CPath::FindFirst(uint32_t dwAttributes /*= _A_NORMAL*/)
{ {
m_dwFindFileAttributes =dwAttributes; m_dwFindFileAttributes =dwAttributes;
BOOL bGotFile; BOOL bGotFile;
@ -908,7 +908,7 @@ BOOL CPath::FindFirst(ULONG dwAttributes /*= _A_NORMAL*/)
// Task : Find the next file that meets the conditions specified // Task : Find the next file that meets the conditions specified
// in the last FindFirst call // in the last FindFirst call
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::FindNext() bool CPath::FindNext()
{ {
if (m_hFindFile == NULL) if (m_hFindFile == NULL)
return FALSE; return FALSE;
@ -955,12 +955,12 @@ BOOL CPath::FindNext()
// Post : Return TRUE on success // Post : Return TRUE on success
// Task : Change current working directory of application 2 path // Task : Change current working directory of application 2 path
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::ChangeDirectory() bool CPath::ChangeDirectory()
{ {
stdstr DriveDirectory; std::string DriveDirectory;
GetDriveDirectory(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 // Post : Return TRUE on success
// Task : Create new directory // Task : Create new directory
//------------------------------------------------------------- //-------------------------------------------------------------
BOOL CPath::CreateDirectory(BOOL bCreateIntermediates /*= TRUE*/) bool CPath::DirectoryCreate(bool bCreateIntermediates /*= TRUE*/)
{ {
stdstr PathText; std::string PathText;
BOOL bSuccess; bool bSuccess;
GetDriveDirectory(PathText); GetDriveDirectory(PathText);
StripTrailingBackslash(PathText); StripTrailingBackslash(PathText);
bSuccess =::CreateDirectory(PathText.c_str(),NULL); bSuccess =::CreateDirectory(PathText.c_str(),NULL) != 0;
if(!bSuccess) if(!bSuccess)
{ {
CPath CurrentDir(CPath::CURRENT_DIRECTORY); CPath CurrentDir(CPath::CURRENT_DIRECTORY);
bSuccess = ChangeDirectory(); bSuccess = ChangeDirectory() != 0;
CurrentDir.ChangeDirectory(); CurrentDir.ChangeDirectory();
} }
if(!bSuccess && bCreateIntermediates) if(!bSuccess && bCreateIntermediates)
{ {
stdstr::size_type nDelimiter =PathText.rfind(DIRECTORY_DELIMITER); std::string::size_type nDelimiter =PathText.rfind(DIRECTORY_DELIMITER);
if(nDelimiter == stdstr::npos) if(nDelimiter == std::string::npos)
return FALSE; return FALSE;
PathText.resize(nDelimiter + 1); PathText.resize(nDelimiter + 1);
CPath SubPath(PathText); CPath SubPath(PathText);
if(SubPath.CreateDirectory()) if (SubPath.DirectoryCreate())
return CreateDirectory(FALSE); return DirectoryCreate(false);
else else
return FALSE; return FALSE;
} }
@ -1007,7 +1007,7 @@ BOOL CPath::CreateDirectory(BOOL bCreateIntermediates /*= TRUE*/)
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Task : Remove first character (if any) if it's chLeading // 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 = "\\\\"; 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) if(nLength == 0)
return; return;
@ -1045,9 +1045,9 @@ void CPath::StripLeadingChar(stdstr& rText, TCHAR chLeading) const
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Task : Remove first character if \ // 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 Directory is of the form '\', don't do it
if(nLength <= 1) if(nLength <= 1)
@ -1060,9 +1060,9 @@ void CPath::StripLeadingBackslash(stdstr& Directory) const
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Task : Remove last character (if any) if it's chTrailing // 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) if(nLength == 0)
return; return;
@ -1073,11 +1073,11 @@ void CPath::StripTrailingChar(stdstr& rText, TCHAR chTrailing) const
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Task : Remove last character if \ // Task : Remove last character if \
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void CPath::StripTrailingBackslash(stdstr& rDirectory) const void CPath::StripTrailingBackslash(std::string& rDirectory) const
{ {
for (;;) for (;;)
{ {
stdstr::size_type nLength = rDirectory.length(); std::string::size_type nLength = rDirectory.length();
if(nLength <= 1) if(nLength <= 1)
{ {
return; return;
@ -1096,23 +1096,24 @@ void CPath::StripTrailingBackslash(stdstr& rDirectory) const
// Task : Add a backslash to the end of Directory if there is // Task : Add a backslash to the end of Directory if there is
// not already one there // 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)) if (Directory.empty() || (Directory[nLength - 1] != DIRECTORY_DELIMITER))
{
Directory += DIRECTORY_DELIMITER; Directory += DIRECTORY_DELIMITER;
} }
}
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Task : Add a backslash to the beginning of Directory if there // Task : Add a backslash to the beginning of Directory if there
// is not already one 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)) if(Directory.empty() || (Directory[0] != DIRECTORY_DELIMITER))
{ {
stdstr temp =Directory; Directory = stdstr_f("%c%s", DIRECTORY_DELIMITER, Directory.c_str());
Directory.Format(_T("%c%s"),DIRECTORY_DELIMITER,temp.c_str());
} }
} }

View File

@ -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 #pragma once
#endif // _MSC_VER > 1000 #include <string>
#include "stdtypes.h"
#include "std string.h"
#include <sys\types.h>
#include <dos.h>
#include <WTypes.h>
class CPathException class CPathException
{ {
public: public:
ULONG m_dwErrorCode; uint32_t m_dwErrorCode;
public: public:
CPathException(ULONG code =0): m_dwErrorCode(code) {} CPathException(uint32_t code =0): m_dwErrorCode(code) {}
}; };
class CPath class CPath
@ -43,10 +25,10 @@ public:
//Attributes //Attributes
private: private:
stdstr m_strPath; std::string m_strPath;
ULONG m_dwFindFileAttributes; uint32_t m_dwFindFileAttributes;
HANDLE m_hFindFile; void * m_hFindFile;
static HINSTANCE m_hInst; static void * m_hInst;
public: public:
//Methods //Methods
@ -54,15 +36,15 @@ public:
//Construction / destruction //Construction / destruction
CPath(); CPath();
CPath(const CPath& rPath); CPath(const CPath& rPath);
CPath(LPCTSTR lpszPath); CPath(const char * lpszPath);
CPath(LPCTSTR lpszPath, LPCTSTR NameExten); CPath(const char * lpszPath, const char * NameExten);
CPath(LPCTSTR lpszPath, const stdstr& NameExten); CPath(const char * lpszPath, const std::string & NameExten);
CPath(const stdstr& strPath); CPath(const std::string& strPath);
CPath(const stdstr& strPath, LPCTSTR NameExten); CPath(const std::string& strPath, const char * NameExten);
CPath(const stdstr& strPath, const stdstr& NameExten); CPath(const std::string& strPath, const std::string& NameExten);
CPath(DIR_CURRENT_DIRECTORY sdt, LPCTSTR NameExten = NULL); CPath(DIR_CURRENT_DIRECTORY sdt, const char * NameExten = NULL);
CPath(DIR_MODULE_DIRECTORY sdt, LPCTSTR NameExten = NULL); CPath(DIR_MODULE_DIRECTORY sdt, const char * NameExten = NULL);
CPath(DIR_MODULE_FILE sdt); CPath(DIR_MODULE_FILE sdt);
virtual ~CPath(); virtual ~CPath();
@ -73,95 +55,93 @@ public:
//Operators //Operators
CPath& operator = (const CPath& rPath); CPath& operator = (const CPath& rPath);
CPath& operator = (LPCTSTR lpszPath); CPath& operator = (const char * lpszPath);
CPath& operator = (const stdstr& strPath); CPath& operator = (const std::string & strPath);
BOOL operator == (const CPath& rPath) const; bool operator == (const CPath& rPath) const;
BOOL operator != (const CPath& rPath) const; bool operator != (const CPath& rPath) const;
operator LPCTSTR() const; operator const char *() const;
operator stdstr&() { return m_strPath; } operator std::string &() { return m_strPath; }
//Get path components //Get path components
void GetDriveDirectory(stdstr& rDriveDirectory) const; void GetDriveDirectory(std::string & rDriveDirectory) const;
stdstr GetDriveDirectory(void) const; std::string GetDriveDirectory(void) const;
void GetDirectory(stdstr& rDirectory) const; void GetDirectory(std::string& rDirectory) const;
stdstr GetDirectory(void) const; std::string GetDirectory(void) const;
void GetName(stdstr& rName) const; void GetName(std::string& rName) const;
stdstr GetName(void) const; std::string GetName(void) const;
void GetNameExtension(stdstr& rNameExtension) const; void GetNameExtension(std::string& rNameExtension) const;
stdstr GetNameExtension(void) const; std::string GetNameExtension(void) const;
void GetExtension(stdstr& rExtension) const; void GetExtension(std::string& rExtension) const;
stdstr GetExtension(void) const; std::string GetExtension(void) const;
void GetCurrentDirectory(stdstr& rDrive) const; void GetCurrentDirectory(std::string& rDrive) const;
stdstr GetCurrentDirectory(void) const; std::string GetCurrentDirectory(void) const;
void GetFullyQualified(stdstr& rFullyQualified) const; void GetFullyQualified(std::string& rFullyQualified) const;
void GetComponents(stdstr* pDrive =NULL, void GetComponents(std::string* pDrive = NULL,
stdstr* pDirectory =NULL, std::string* pDirectory =NULL,
stdstr* pName =NULL, std::string* pName = NULL,
stdstr* pExtension =NULL) const; std::string* pExtension = NULL) const;
//Get other state //Get other state
BOOL IsEmpty() const { return m_strPath.empty(); } bool IsEmpty() const { return m_strPath.empty(); }
BOOL IsRelative() const; bool IsRelative() const;
//Set path components //Set path components
void SetDrive(TCHAR chDrive); void SetDrive(char chDrive);
void SetDriveDirectory(LPCTSTR lpszDriveDirectory); void SetDriveDirectory(const char * lpszDriveDirectory);
void SetDirectory(LPCTSTR lpszDirectory, BOOL bEnsureAbsolute =FALSE); void SetDirectory(const char * lpszDirectory, bool bEnsureAbsolute = false);
void SetName(LPCTSTR lpszName); void SetName(const char * lpszName);
void SetName(int iName); void SetName(int iName);
void SetNameExtension(LPCTSTR lpszNameExtension); void SetNameExtension(const char * lpszNameExtension);
void SetExtension(LPCTSTR lpszExtension); void SetExtension(const char * lpszExtension);
void SetExtension(int iExtension); void SetExtension(int iExtension);
void AppendDirectory(LPCTSTR lpszSubDirectory); void AppendDirectory(const char * lpszSubDirectory);
void UpDirectory(stdstr* pLastDirectory =NULL); void UpDirectory(std::string* pLastDirectory = NULL);
void SetComponents(LPCTSTR lpszDrive, void SetComponents(const char * lpszDrive,
LPCTSTR lpszDirectory, const char * lpszDirectory,
LPCTSTR lpszName, const char * lpszName,
LPCTSTR lpszExtension); const char * lpszExtension);
//Set whole path //Set whole path
void Empty() { m_strPath.erase(); } void Empty() { m_strPath.erase(); }
void CurrentDirectory(); void CurrentDirectory();
void Module(); void Module();
void Module(HINSTANCE hInstance); void Module(void * hInstance);
void ModuleDirectory(); void ModuleDirectory();
void ModuleDirectory(HINSTANCE hInstance); void ModuleDirectory(void * hInstance);
//Directory information //Directory information
BOOL IsDirectory() const; bool IsDirectory() const;
BOOL DirectoryExists() const; bool DirectoryExists() const;
//File Information //File Information
BOOL IsFile() const { return !IsDirectory(); } bool IsFile() const { return !IsDirectory(); }
BOOL Exists() const; bool Exists() const;
//Directory operations //Directory operations
BOOL CreateDirectory(BOOL bCreateIntermediates =TRUE); bool DirectoryCreate(bool bCreateIntermediates = true);
BOOL ChangeDirectory(); bool ChangeDirectory();
//File operations //File operations
BOOL Delete(BOOL bEvenIfReadOnly =TRUE) const; bool Delete(bool bEvenIfReadOnly = true) const;
BOOL CopyTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite =TRUE); bool CopyTo(const char * lpcszTargetFile, bool bOverwrite = true);
BOOL MoveTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite =TRUE); bool MoveTo(const char * lpcszTargetFile, bool bOverwrite = true);
//Finders //Finders
BOOL FindFirst(ULONG dwAttributes =_A_NORMAL); bool FindFirst(uint32_t dwAttributes = 0);
BOOL FindNext(); bool FindNext();
// Helpers // Helpers
static void SethInst ( HINSTANCE hInst ); static void SethInst(void * hInst);
static HINSTANCE GethInst(); static void * GethInst();
private: private:
BOOL AttributesMatch(ULONG dwTargetAttributes, ULONG dwFileAttributes); bool AttributesMatch(uint32_t dwTargetAttributes, uint32_t dwFileAttributes);
void cleanPathString(stdstr& rDirectory) const; void cleanPathString(std::string& rDirectory) const;
void StripLeadingChar(stdstr& rText, TCHAR chLeading) const; void StripLeadingChar(std::string& rText, char chLeading) const;
void StripLeadingBackslash(stdstr& Directory) const; void StripLeadingBackslash(std::string& Directory) const;
void StripTrailingChar(stdstr& rText, TCHAR chTrailing) const; void StripTrailingChar(std::string& rText, char chTrailing) const;
void StripTrailingBackslash(stdstr& rDirectory) const; void StripTrailingBackslash(std::string& rDirectory) const;
void EnsureTrailingBackslash(stdstr& Directory) const; void EnsureTrailingBackslash(std::string& Directory) const;
void EnsureLeadingBackslash(stdstr& Directory) const; void EnsureLeadingBackslash(std::string& Directory) const;
}; };
#endif // !defined(AFX_PATH_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_)

View File

@ -2,7 +2,6 @@
#include <map> #include <map>
#include <windows.h> #include <windows.h>
#include <exception>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -29,6 +29,7 @@
#include "TxDbg.h" #include "TxDbg.h"
#include <zlib/zlib.h> #include <zlib/zlib.h>
#include <Common/path.h> #include <Common/path.h>
#include <common/std string.h>
TxCache::~TxCache() TxCache::~TxCache()
{ {
@ -233,7 +234,7 @@ TxCache::save(const wchar_t *path, const wchar_t *filename, int config)
char cbuf[MAX_PATH]; char cbuf[MAX_PATH];
CPath cachepath(stdstr().FromUTF16(path),""); CPath cachepath(stdstr().FromUTF16(path),"");
cachepath.CreateDirectory(); cachepath.DirectoryCreate();
/* Ugly hack to enable fopen/gzopen in Win9x */ /* Ugly hack to enable fopen/gzopen in Win9x */
#ifdef _WIN32 #ifdef _WIN32

View File

@ -26,6 +26,7 @@
#endif #endif
#include <common/path.h> #include <common/path.h>
#include <common/std string.h>
#include "TxFilter.h" #include "TxFilter.h"
#include "TextureFilters.h" #include "TextureFilters.h"
#include "TxDbg.h" #include "TxDbg.h"
@ -613,15 +614,15 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf
/* create directories */ /* create directories */
tmpbuf.AppendDirectory("texture_dump"); tmpbuf.AppendDirectory("texture_dump");
if (!tmpbuf.DirectoryExists() && !tmpbuf.CreateDirectory()) if (!tmpbuf.DirectoryExists() && !tmpbuf.DirectoryCreate())
return 0; return 0;
tmpbuf.AppendDirectory(stdstr().FromUTF16(_ident.c_str()).c_str()); tmpbuf.AppendDirectory(stdstr().FromUTF16(_ident.c_str()).c_str());
if (!tmpbuf.DirectoryExists() && !tmpbuf.CreateDirectory()) if (!tmpbuf.DirectoryExists() && !tmpbuf.DirectoryCreate())
return 0; return 0;
tmpbuf.AppendDirectory("GlideHQ"); tmpbuf.AppendDirectory("GlideHQ");
if (!tmpbuf.DirectoryExists() && !tmpbuf.CreateDirectory()) if (!tmpbuf.DirectoryExists() && !tmpbuf.DirectoryCreate())
return 0; return 0;
if ((n64fmt >> 8) == 0x2) { if ((n64fmt >> 8) == 0x2) {

View File

@ -61,6 +61,8 @@
#include <zlib/zlib.h> #include <zlib/zlib.h>
#include <string> #include <string>
#include <common/path.h> #include <common/path.h>
#include <common/std string.h>
#include <io.h>
TxHiResCache::~TxHiResCache() TxHiResCache::~TxHiResCache()
{ {
@ -73,7 +75,7 @@ TxHiResCache::~TxHiResCache()
cachepath.AppendDirectory("cache"); cachepath.AppendDirectory("cache");
int config = _options & (HIRESTEXTURES_MASK|COMPRESS_HIRESTEX|COMPRESSION_MASK|TILE_HIRESTEX|FORCE16BPP_HIRESTEX|GZ_HIRESTEXCACHE|LET_TEXARTISTS_FLY); 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 #endif
@ -115,7 +117,7 @@ TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options,
cachepath.AppendDirectory("cache"); cachepath.AppendDirectory("cache");
int config = _options & (HIRESTEXTURES_MASK|COMPRESS_HIRESTEX|COMPRESSION_MASK|TILE_HIRESTEX|FORCE16BPP_HIRESTEX|GZ_HIRESTEXCACHE|LET_TEXARTISTS_FLY); 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 #endif
@ -236,7 +238,7 @@ boolean TxHiResCache::loadHiResTextures(LPCSTR dir_path, boolean replace)
/* read in Rice's file naming convention */ /* read in Rice's file naming convention */
#define CRCFMTSIZ_LEN 13 #define CRCFMTSIZ_LEN 13
#define PALCRC_LEN 9 #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! /* XXX case sensitivity fiasco!
* files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci
* and file extensions must be in lower case letters! */ * and file extensions must be in lower case letters! */

View File

@ -33,6 +33,7 @@
#include <zlib/zlib.h> #include <zlib/zlib.h>
#include <string> #include <string>
#include <Common/path.h> #include <Common/path.h>
#include <common/std string.h>
TxTexCache::~TxTexCache() TxTexCache::~TxTexCache()
{ {
@ -45,7 +46,7 @@ TxTexCache::~TxTexCache()
int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE); 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 #endif
} }
@ -66,7 +67,7 @@ TxTexCache::TxTexCache(int options, int cachesize, const wchar_t *path, const wc
cachepath.AppendDirectory("cache"); cachepath.AppendDirectory("cache");
int config = _options & (FILTER_MASK|ENHANCEMENT_MASK|COMPRESS_TEX|COMPRESSION_MASK|FORCE16BPP_TEX|GZ_TEXCACHE); 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 #endif
} }

View File

@ -149,7 +149,7 @@ void CEeprom::LoadEeprom()
if (!FileName.DirectoryExists()) 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, m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,

View File

@ -139,7 +139,7 @@ bool CFlashram::LoadFlashram()
if (!FileName.DirectoryExists()) 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, m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,

View File

@ -43,7 +43,7 @@ void LoadMempak (int Control)
if (!FileName.DirectoryExists()) if (!FileName.DirectoryExists())
{ {
FileName.CreateDirectory(); FileName.DirectoryCreate();
} }
BYTE Initialize[] = { BYTE Initialize[] = {

View File

@ -36,7 +36,7 @@ bool CSram::LoadSram()
if (!FileName.DirectoryExists()) 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, m_hFile = CreateFile(FileName,m_ReadOnly ? GENERIC_READ : GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,

View File

@ -387,7 +387,7 @@ bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const
if (CopyFile(srcGfxPlugin,dstGfxPlugin,false) == 0) 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)) if (!CopyFile(srcGfxPlugin,dstGfxPlugin,false))
{ {
return 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 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()); CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
if (CopyFile(srcAudioPlugin,dstAudioPlugin,false) == 0) { 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)) if (!CopyFile(srcAudioPlugin,dstAudioPlugin,false))
{ {
return 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 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()); CPath dstRSPPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
if (CopyFile(srcRSPPlugin,dstRSPPlugin,false) == 0) { 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)) if (!CopyFile(srcRSPPlugin,dstRSPPlugin,false))
{ {
return 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()); CPath dstContPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
if (!srcContPlugin.CopyTo(dstContPlugin)) 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)) if (!CopyFile(srcContPlugin,dstContPlugin,false))
{ {
DWORD dwError = GetLastError(); DWORD dwError = GetLastError();

View File

@ -3,21 +3,14 @@
class CPluginList class CPluginList
{ {
public: public:
typedef struct { typedef struct
{
PLUGIN_INFO Info; PLUGIN_INFO Info;
bool AboutFunction; bool AboutFunction;
CPath FullPath; CPath FullPath;
stdstr FileName; stdstr FileName;
} PLUGIN; } PLUGIN;
private:
typedef std::vector<PLUGIN> PluginList;
PluginList m_PluginList;
CPath m_PluginDir;
void AddPluginFromDir ( CPath Dir);
public: public:
CPluginList(bool bAutoFill = true); CPluginList(bool bAutoFill = true);
~CPluginList(); ~CPluginList();
@ -26,4 +19,12 @@ public:
int GetPluginCount ( void ) const; int GetPluginCount ( void ) const;
const PLUGIN * GetPluginInfo ( int indx ) const; const PLUGIN * GetPluginInfo ( int indx ) const;
static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo ); static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo );
private:
typedef std::vector<PLUGIN> PluginList;
PluginList m_PluginList;
CPath m_PluginDir;
void AddPluginFromDir(CPath Dir);
}; };

View File

@ -81,7 +81,7 @@ void CSettingTypeApplication::Initialize( const char * /*AppName*/ )
CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(),""); CPath SettingsDir(CPath(SettingsFile).GetDriveDirectory(),"");
if (!SettingsDir.DirectoryExists()) if (!SettingsDir.DirectoryExists())
{ {
SettingsDir.CreateDirectory(); SettingsDir.DirectoryCreate();
} }
m_SettingsIniFile = new CIniFile(SettingsFile.c_str()); m_SettingsIniFile = new CIniFile(SettingsFile.c_str());

View File

@ -11,8 +11,9 @@
#include "stdafx.h" #include "stdafx.h"
#include "SettingsType-Application.h" #include "SettingsType-Application.h"
#include "SettingsType-ApplicationPath.h" #include "SettingsType-ApplicationPath.h"
#include <common/path.h>
CSettingTypeApplicationPath::CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, SettingID DefaultSetting ) : CSettingTypeApplicationPath::CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting ) :
CSettingTypeApplication(Section,Name,DefaultSetting) CSettingTypeApplication(Section,Name,DefaultSetting)
{ {
@ -34,7 +35,7 @@ bool CSettingTypeApplicationPath::Load ( int Index, stdstr & Value ) const
FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str()); FullFilePath.SetNameExtension(RelativePath.GetNameExtension().c_str());
FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str()); FullFilePath.AppendDirectory(RelativePath.GetDirectory().c_str());
Value = FullFilePath; Value = (std::string &)FullFilePath;
} }
} }
return bRes; return bRes;

View File

@ -13,17 +13,20 @@
class CSettingTypeApplicationPath : 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: public:
virtual ~CSettingTypeApplicationPath(); virtual ~CSettingTypeApplicationPath();
CSettingTypeApplicationPath(LPCSTR Section, LPCSTR Name, SettingID DefaultSetting ); CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting );
//return the values //return the values
virtual bool Load ( int Index, stdstr & Value ) const; 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 );
};

View File

@ -12,12 +12,12 @@
#include "SettingsType-RomDatabase.h" #include "SettingsType-RomDatabase.h"
#include "SettingsType-RDBOnOff.h" #include "SettingsType-RDBOnOff.h"
CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(LPCSTR Name, SettingID DefaultSetting ) : CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting ) :
CSettingTypeRomDatabase(Name,DefaultSetting) CSettingTypeRomDatabase(Name,DefaultSetting)
{ {
} }
CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(LPCSTR Name, int DefaultValue ) : CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, int DefaultValue ) :
CSettingTypeRomDatabase(Name,DefaultValue) CSettingTypeRomDatabase(Name,DefaultValue)
{ {
} }
@ -35,7 +35,7 @@ bool CSettingTypeRDBOnOff::Load ( int Index, bool & Value ) const
LoadDefault(Index,Value); LoadDefault(Index,Value);
return false; return false;
} }
LPCSTR String = strValue.c_str(); const char * String = strValue.c_str();
if (_stricmp(String,"On") == 0) { Value = true; } if (_stricmp(String,"On") == 0) { Value = true; }
else if (_stricmp(String,"Off") == 0) { Value = false; } else if (_stricmp(String,"Off") == 0) { Value = false; }
@ -44,20 +44,20 @@ bool CSettingTypeRDBOnOff::Load ( int Index, bool & Value ) const
LoadDefault(Index,Value); LoadDefault(Index,Value);
return false; return false;
} }
else { Notify().BreakPoint(__FILEW__,__LINE__); } else { g_Notify->BreakPoint(__FILEW__,__LINE__); }
return true; return true;
} }
bool CSettingTypeRDBOnOff::Load ( int /*Index*/, ULONG & /*Value*/ ) const bool CSettingTypeRDBOnOff::Load ( int /*Index*/, uint32_t & /*Value*/ ) const
{ {
Notify().BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
return false; return false;
} }
bool CSettingTypeRDBOnOff::Load ( int /*Index*/, stdstr & /*Value*/ ) const bool CSettingTypeRDBOnOff::Load ( int /*Index*/, stdstr & /*Value*/ ) const
{ {
Notify().BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
return false; return false;
} }
@ -75,36 +75,35 @@ void CSettingTypeRDBOnOff::LoadDefault ( int /*Index*/, bool & Value ) const
} }
} }
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 void CSettingTypeRDBOnOff::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) const
{ {
Notify().BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
} }
//Update the settings //Update the settings
void CSettingTypeRDBOnOff::Save ( int /*Index*/, bool Value ) 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*/ ) 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*/ ) void CSettingTypeRDBOnOff::Save ( int /*Index*/, const char * /*Value*/ )
{ {
Notify().BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
} }
void CSettingTypeRDBOnOff::Delete( int /*Index*/ ) void CSettingTypeRDBOnOff::Delete( int /*Index*/ )

View File

@ -13,29 +13,32 @@
class CSettingTypeRDBOnOff : class CSettingTypeRDBOnOff :
public CSettingTypeRomDatabase public CSettingTypeRomDatabase
{ {
public: public:
CSettingTypeRDBOnOff(LPCSTR Name, SettingID DefaultSetting ); CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBOnOff(LPCSTR Name, int DefaultValue ); CSettingTypeRDBOnOff(const char * Name, int DefaultValue );
~CSettingTypeRDBOnOff(); ~CSettingTypeRDBOnOff();
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int Index, bool & Value ) const;
virtual bool Load ( int Index, ULONG & Value ) const; virtual bool Load ( int Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int Index, bool & Value ) const;
virtual void LoadDefault ( int Index, ULONG & Value ) const; virtual void LoadDefault ( int Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int Index, bool Value );
virtual void Save ( int Index, ULONG Value ); virtual void Save ( int Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int Index );
};
private:
CSettingTypeRDBOnOff(void); // Disable default constructor
CSettingTypeRDBOnOff(const CSettingTypeRDBOnOff&); // Disable copy constructor
CSettingTypeRDBOnOff& operator=(const CSettingTypeRDBOnOff&); // Disable assignment
};

View File

@ -12,12 +12,12 @@
#include "SettingsType-RomDatabase.h" #include "SettingsType-RomDatabase.h"
#include "SettingsType-RDBYesNo.h" #include "SettingsType-RDBYesNo.h"
CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(LPCSTR Name, SettingID DefaultSetting ) : CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(const char * Name, SettingID DefaultSetting ) :
CSettingTypeRomDatabase(Name,DefaultSetting) CSettingTypeRomDatabase(Name,DefaultSetting)
{ {
} }
CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(LPCSTR Name, int DefaultValue ) : CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(const char * Name, int DefaultValue ) :
CSettingTypeRomDatabase(Name,DefaultValue) CSettingTypeRomDatabase(Name,DefaultValue)
{ {
} }
@ -35,15 +35,23 @@ bool CSettingTypeRDBYesNo::Load ( int Index, bool & Value ) const
LoadDefault(Index,Value); LoadDefault(Index,Value);
return false; return false;
} }
LPCSTR String = strValue.c_str(); const char * String = strValue.c_str();
if (_stricmp(String,"Yes") == 0) { Value = true; } if (_stricmp(String,"Yes") == 0)
else if (_stricmp(String,"No") == 0) { Value = false; } {
Value = true;
}
else if (_stricmp(String,"No") == 0)
{
Value = false;
}
else if (_stricmp(String,"default") == 0) else if (_stricmp(String,"default") == 0)
{ {
LoadDefault(Index,Value); LoadDefault(Index,Value);
return false; return false;
} else { }
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()); 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); LoadDefault(Index,Value);
return false; return false;
@ -52,7 +60,7 @@ bool CSettingTypeRDBYesNo::Load ( int Index, bool & Value ) const
return true; return true;
} }
bool CSettingTypeRDBYesNo::Load ( int /*Index*/, ULONG & /*Value*/ ) const bool CSettingTypeRDBYesNo::Load ( int /*Index*/, uint32_t & /*Value*/ ) const
{ {
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
return false; return false;
@ -78,7 +86,7 @@ void CSettingTypeRDBYesNo::LoadDefault ( int /*Index*/, bool & Value ) const
} }
} }
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__);
} }
@ -88,14 +96,13 @@ void CSettingTypeRDBYesNo::LoadDefault ( int /*Index*/, stdstr & /*Value*/ ) con
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__,__LINE__);
} }
//Update the settings //Update the settings
void CSettingTypeRDBYesNo::Save ( int /*Index*/, bool Value ) 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");
} }

View File

@ -13,29 +13,32 @@
class CSettingTypeRDBYesNo : class CSettingTypeRDBYesNo :
public CSettingTypeRomDatabase public CSettingTypeRomDatabase
{ {
public: public:
CSettingTypeRDBYesNo(LPCSTR Name, SettingID DefaultSetting ); CSettingTypeRDBYesNo(const char * Name, SettingID DefaultSetting );
CSettingTypeRDBYesNo(LPCSTR Name, int DefaultValue ); CSettingTypeRDBYesNo(const char * Name, int DefaultValue );
~CSettingTypeRDBYesNo(); ~CSettingTypeRDBYesNo();
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int Index, bool & Value ) const;
virtual bool Load ( int Index, ULONG & Value ) const; virtual bool Load ( int Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int Index, stdstr & Value ) const;
//return the default values //return the default values
virtual void LoadDefault ( int Index, bool & Value ) const; virtual void LoadDefault ( int Index, bool & Value ) const;
virtual void LoadDefault ( int Index, ULONG & Value ) const; virtual void LoadDefault ( int Index, uint32_t & Value ) const;
virtual void LoadDefault ( int Index, stdstr & Value ) const; virtual void LoadDefault ( int Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int Index, bool Value );
virtual void Save ( int Index, ULONG Value ); virtual void Save ( int Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int Index, const stdstr & Value );
virtual void Save ( int Index, const char * Value ); virtual void Save ( int Index, const char * Value );
// Delete the setting // Delete the setting
virtual void Delete ( int Index ); virtual void Delete ( int Index );
};
private:
CSettingTypeRDBYesNo(void); // Disable default constructor
CSettingTypeRDBYesNo(const CSettingTypeRDBYesNo&); // Disable copy constructor
CSettingTypeRDBYesNo& operator=(const CSettingTypeRDBYesNo&); // Disable assignment
};

View File

@ -11,7 +11,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "SettingsType-RomDatabaseSetting.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), CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault),
m_SectionIdent(SectionIdent) 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), CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault),
m_SectionIdent(SectionIdent) 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), CSettingTypeRomDatabase(Name, DefaultValue, DeleteOnDefault),
m_SectionIdent(SectionIdent) 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), CSettingTypeRomDatabase(Name, DefaultSetting, DeleteOnDefault),
m_SectionIdent(SectionIdent) m_SectionIdent(SectionIdent)
{ {

View File

@ -16,18 +16,22 @@ class CSettingTypeRomDatabaseSetting :
public CSettingTypeRomDatabase public CSettingTypeRomDatabase
{ {
public: public:
CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, LPCSTR DefaultValue, bool DeleteOnDefault = false ); CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, const char * DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, bool DefaultValue, bool DeleteOnDefault = false ); CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, bool DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, int DefaultValue, bool DeleteOnDefault = false ); CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, int DefaultValue, bool DeleteOnDefault = false );
CSettingTypeRomDatabaseSetting(LPCSTR SectionIdent, LPCSTR Name, SettingID DefaultSetting, bool DeleteOnDefault = false ); CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false );
virtual ~CSettingTypeRomDatabaseSetting(); virtual ~CSettingTypeRomDatabaseSetting();
virtual SettingType GetSettingType ( void ) const { return SettingType_RdbSetting; } virtual SettingType GetSettingType ( void ) const { return SettingType_RdbSetting; }
private: 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
};

View File

@ -3,36 +3,39 @@
class CSettingTypeRomDatabase : 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: public:
CSettingTypeRomDatabase(LPCSTR Name, LPCSTR DefaultValue ); CSettingTypeRomDatabase(const char * Name, const char * DefaultValue );
CSettingTypeRomDatabase(LPCSTR Name, bool DefaultValue ); CSettingTypeRomDatabase(const char * Name, bool DefaultValue );
CSettingTypeRomDatabase(LPCSTR Name, int DefaultValue ); CSettingTypeRomDatabase(const char * Name, int DefaultValue );
CSettingTypeRomDatabase(LPCSTR Name, SettingID DefaultSetting ); CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting );
~CSettingTypeRomDatabase(); ~CSettingTypeRomDatabase();
virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; } virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; }
//return the values //return the values
virtual bool Load ( int Index, bool & Value ) const; virtual bool Load ( int Index, bool & Value ) const;
virtual bool Load ( int Index, ULONG & Value ) const; virtual bool Load ( int Index, uint32_t & Value ) const;
virtual bool Load ( int Index, stdstr & Value ) const; virtual bool Load ( int Index, stdstr & Value ) const;
//Update the settings //Update the settings
virtual void Save ( int Index, bool Value ); virtual void Save ( int Index, bool Value );
virtual void Save ( int Index, ULONG Value ); virtual void Save ( int Index, uint32_t Value );
virtual void Save ( int Index, const stdstr & Value ); virtual void Save ( int Index, const stdstr & Value );
virtual void Save ( int Index, const char * 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;
};

View File

@ -13,14 +13,13 @@ 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); CPath LogFilePath(CPath::MODULE_DIRECTORY);
LogFilePath.AppendDirectory("Logs"); LogFilePath.AppendDirectory("Logs");
if (!LogFilePath.DirectoryExists()) if (!LogFilePath.DirectoryExists())
{ {
LogFilePath.CreateDirectory(); LogFilePath.DirectoryCreate();
} }
LogFilePath.SetNameExtension("Project64.log"); LogFilePath.SetNameExtension("Project64.log");
@ -36,7 +35,6 @@ void InitializeLog ( void)
g_Settings->RegisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged); g_Settings->RegisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged);
} }
/*bool ChangeDirPermission ( const CPath & Dir) /*bool ChangeDirPermission ( const CPath & Dir)
{ {
if (Dir.DirectoryExists()) if (Dir.DirectoryExists())
@ -64,7 +62,6 @@ void InitializeLog ( void)
if (ea.Trustee.TrusteeType == TRUSTEE_IS_SID) if (ea.Trustee.TrusteeType == TRUSTEE_IS_SID)
{ {
} }
bAdd = false; bAdd = false;
} }
@ -98,23 +95,23 @@ void FixDirectories ( void )
{ {
CPath Directory(CPath::MODULE_DIRECTORY); CPath Directory(CPath::MODULE_DIRECTORY);
Directory.AppendDirectory("Config"); Directory.AppendDirectory("Config");
if (!Directory.DirectoryExists()) Directory.CreateDirectory(); if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory(); Directory.UpDirectory();
Directory.AppendDirectory("Logs"); Directory.AppendDirectory("Logs");
if (!Directory.DirectoryExists()) Directory.CreateDirectory(); if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory(); Directory.UpDirectory();
Directory.AppendDirectory("Save"); Directory.AppendDirectory("Save");
if (!Directory.DirectoryExists()) Directory.CreateDirectory(); if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory(); Directory.UpDirectory();
Directory.AppendDirectory("Screenshots"); Directory.AppendDirectory("Screenshots");
if (!Directory.DirectoryExists()) Directory.CreateDirectory(); if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
Directory.UpDirectory(); Directory.UpDirectory();
Directory.AppendDirectory("textures"); Directory.AppendDirectory("textures");
if (!Directory.DirectoryExists()) Directory.CreateDirectory(); if (!Directory.DirectoryExists()) Directory.DirectoryCreate();
} }
bool TerminatedExistingEmu() bool TerminatedExistingEmu()
@ -243,7 +240,7 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /
CMainGui MainWindow(true,WinTitle.c_str()), HiddenWindow(false); CMainGui MainWindow(true,WinTitle.c_str()), HiddenWindow(false);
CMainMenu MainMenu(&MainWindow); CMainMenu MainMenu(&MainWindow);
g_Plugins->SetRenderWindows(&MainWindow,&HiddenWindow); g_Plugins->SetRenderWindows(&MainWindow,&HiddenWindow);
g_Notify->SetMainWindow(&MainWindow); Notify().SetMainWindow(&MainWindow);
if (__argc > 1) if (__argc > 1)
{ {