From 48ca426be409e098fb8b5954c2c630775209b9cf Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 24 Nov 2009 08:32:39 +0000 Subject: [PATCH] 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 --- common/include/Utilities/Path.h | 5 ++++- common/include/Utilities/Threading.h | 2 ++ common/src/Utilities/PathUtils.cpp | 14 ++++++++++++++ common/src/Utilities/ThreadTools.cpp | 5 +++++ pcsx2/Elfheader.cpp | 5 ++--- pcsx2/gui/AppInit.cpp | 2 +- pcsx2/gui/AppMain.cpp | 4 +++- pcsx2/gui/Panels/DirPickerPanel.cpp | 12 ++++-------- pcsx2/gui/RecentIsoList.cpp | 4 +--- 9 files changed, 36 insertions(+), 17 deletions(-) diff --git a/common/include/Utilities/Path.h b/common/include/Utilities/Path.h index 145375545e..f291c18071 100644 --- a/common/include/Utilities/Path.h +++ b/common/include/Utilities/Path.h @@ -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 ); diff --git a/common/include/Utilities/Threading.h b/common/include/Utilities/Threading.h index 31a3b068b9..3ab52bf1ad 100644 --- a/common/include/Utilities/Threading.h +++ b/common/include/Utilities/Threading.h @@ -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 ); diff --git a/common/src/Utilities/PathUtils.cpp b/common/src/Utilities/PathUtils.cpp index e521f096ac..c7d1ff99e8 100644 --- a/common/src/Utilities/PathUtils.cpp +++ b/common/src/Utilities/PathUtils.cpp @@ -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. // diff --git a/common/src/Utilities/ThreadTools.cpp b/common/src/Utilities/ThreadTools.cpp index 25737303ce..f58b58e020 100644 --- a/common/src/Utilities/ThreadTools.cpp +++ b/common/src/Utilities/ThreadTools.cpp @@ -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 ); diff --git a/pcsx2/Elfheader.cpp b/pcsx2/Elfheader.cpp index 4e6502a768..51eea99389 100644 --- a/pcsx2/Elfheader.cpp +++ b/pcsx2/Elfheader.cpp @@ -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; iFolders.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); } } diff --git a/pcsx2/gui/RecentIsoList.cpp b/pcsx2/gui/RecentIsoList.cpp index d0a939184d..971b98f7a3 100644 --- a/pcsx2/gui/RecentIsoList.cpp +++ b/pcsx2/gui/RecentIsoList.cpp @@ -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();