Added AtomicBitTestAndReset() to thread tools and added a Normalize helper to 'Path' namespace.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2242 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-11-24 08:32:39 +00:00
parent 856bcef278
commit 48ca426be4
9 changed files with 36 additions and 17 deletions

View File

@ -126,7 +126,10 @@ namespace Path
{
extern bool IsRelative( const wxString& path );
extern s64 GetFileSize( const wxString& path );
extern wxString Normalize( const wxString& srcpath );
extern wxString Normalize( wxDirName srcpath );
extern wxString Combine( const wxString& srcPath, const wxString& srcFile );
extern wxString Combine( const wxDirName& srcPath, const wxFileName& srcFile );
extern wxString Combine( const wxString& srcPath, const wxDirName& srcFile );

View File

@ -162,6 +162,8 @@ namespace Threading
extern s32 AtomicIncrement( volatile s32& Target );
extern s32 AtomicDecrement( volatile s32& Target );
extern bool AtomicBitTestAndReset( volatile u32& bitset, u8 bit );
extern void* _AtomicExchangePointer( void * volatile * const target, void* const value );
extern void* _AtomicCompareExchangePointer( void * volatile * const target, void* const value, void* const comparand );

View File

@ -108,6 +108,20 @@ s64 Path::GetFileSize( const wxString& path )
return (s64)wxFileName::GetSize( path ).GetValue();
}
wxString Path::Normalize( const wxString& src )
{
wxFileName normalize( src );
normalize.Normalize();
return normalize.GetFullPath();
}
wxString Path::Normalize( wxDirName src )
{
src.Normalize();
return src.ToString();
}
// Concatenates two pathnames together, inserting delimiters (backslash on win32)
// as needed! Assumes the 'dest' is allocated to at least g_MaxPath length.
//

View File

@ -609,6 +609,11 @@ void Threading::WaitEvent::Wait()
// --------------------------------------------------------------------------------------
// define some overloads for InterlockedExchanges for commonly used types, like u32 and s32.
__forceinline bool Threading::AtomicBitTestAndReset( volatile u32& bitset, u8 bit )
{
return _interlockedbittestandreset( (volatile long*)& bitset, bit ) != 0;
}
__forceinline u32 Threading::AtomicExchange( volatile u32& Target, u32 value )
{
return _InterlockedExchange( (volatile long*)&Target, value );

View File

@ -613,8 +613,6 @@ void loadElfFile(const wxString& filename)
// 2 - PS2 CD
int GetPS2ElfName( wxString& name )
{
char buffer[512];
try {
IsoFSCDVD isofs;
IsoFile file( isofs, L"SYSTEM.CNF;1");
@ -673,6 +671,7 @@ int GetPS2ElfName( wxString& name )
#ifdef PCSX2_DEVBUILD
FILE *fp;
int i;
char buffer[512];
fp = fopen("System.map", "r");
if( fp == NULL ) return 2;
@ -686,7 +685,7 @@ int GetPS2ElfName( wxString& name )
for (i=2; i<10; i++) buffer[i] = fgetc(fp); buffer[i] = 0;
addr = strtoul(buffer, (char**)NULL, 0);
fseek(fp, 3, SEEK_CUR);
for (i=0; i<g_MaxPath; i++) {
for (i=0; i<512; i++) {
buffer[i] = fgetc(fp);
if (buffer[i] == '\n' || buffer[i] == 0) break;
}

View File

@ -63,7 +63,7 @@ void Pcsx2App::OpenWizardConsole()
//
void Pcsx2App::ReadUserModeSettings()
{
wxString cwd( wxGetCwd() );
wxString cwd( Path::Normalize( wxGetCwd() ) );
u32 hashres = HashTools::Hash( (char*)cwd.c_str(), cwd.Length() );
wxDirName usrlocaldir( wxStandardPaths::Get().GetUserLocalDataDir() );

View File

@ -300,7 +300,9 @@ void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent&
if( result == pxID_CUSTOM )
{
exit(-5); // fastest way to kill the process?
// fastest way to kill the process!
// (note: SIGTERM is a "handled" kill that performs shutdown stuff, which typically juse crashes anyway)
wxKill( wxGetProcessId(), wxSIGKILL );
}
else if( result == wxID_CANCEL )
{

View File

@ -23,10 +23,7 @@
static wxString GetNormalizedConfigFolder( FoldersEnum_t folderId )
{
const bool isDefault = g_Conf->Folders.IsDefault( folderId );
wxDirName normalized( isDefault ? PathDefs::Get(folderId) : g_Conf->Folders[folderId] );
normalized.Normalize( wxPATH_NORM_ALL );
return normalized.ToString();
return Path::Normalize( g_Conf->Folders.IsDefault( folderId ) ? PathDefs::Get(folderId) : g_Conf->Folders[folderId] );
}
// Pass me TRUE if the default path is to be used, and the DirPickerCtrl disabled from use.
@ -35,11 +32,10 @@ void Panels::DirPickerPanel::UpdateCheckStatus( bool someNoteworthyBoolean )
m_pickerCtrl->Enable( !someNoteworthyBoolean );
if( someNoteworthyBoolean )
{
wxDirName normalized( PathDefs::Get( m_FolderId ) );
normalized.Normalize( wxPATH_NORM_ALL );
m_pickerCtrl->SetPath( normalized.ToString() );
wxString normalized( Path::Normalize( PathDefs::Get( m_FolderId ) ) );
m_pickerCtrl->SetPath( normalized );
wxFileDirPickerEvent event( m_pickerCtrl->GetEventType(), m_pickerCtrl, m_pickerCtrl->GetId(), normalized.ToString() );
wxFileDirPickerEvent event( m_pickerCtrl->GetEventType(), m_pickerCtrl, m_pickerCtrl->GetId(), normalized );
m_pickerCtrl->GetEventHandler()->ProcessEvent(event);
}
}

View File

@ -89,9 +89,7 @@ void RecentIsoManager::Add( const wxString& src )
{
if( src.IsEmpty() ) return;
wxFileName temp( src );
temp.Normalize();
wxString normalized( temp.GetFullPath() );
wxString normalized( Path::Normalize( src ) );
int cnt = m_Items.size();