Core: get CSettingTypeSelectedDirectory to Normalize the path

This commit is contained in:
zilmar 2025-05-15 15:27:04 +09:30
parent beca3ef513
commit dd281e4e34
3 changed files with 11 additions and 3 deletions

View File

@ -1404,7 +1404,7 @@ bool CPath::ChangeDirectory()
#endif #endif
} }
void CPath::NormalizePath(CPath BaseDir) CPath & CPath::NormalizePath(CPath BaseDir)
{ {
#ifdef _WIN32 #ifdef _WIN32
stdstr Directory = BaseDir.GetDriveDirectory(); stdstr Directory = BaseDir.GetDriveDirectory();
@ -1449,6 +1449,7 @@ void CPath::NormalizePath(CPath BaseDir)
SetDirectory(Directory.c_str()); SetDirectory(Directory.c_str());
#endif #endif
} }
return *this;
} }
// Pre: If bCreateIntermediates is TRUE, create all eventually missing parent directories too // Pre: If bCreateIntermediates is TRUE, create all eventually missing parent directories too

View File

@ -127,7 +127,7 @@ public:
// Directory operations // Directory operations
bool DirectoryCreate(bool bCreateIntermediates = true); bool DirectoryCreate(bool bCreateIntermediates = true);
bool ChangeDirectory(); bool ChangeDirectory();
void NormalizePath(CPath BaseDir); CPath & NormalizePath(CPath BaseDir);
// File operations // File operations
bool Delete(bool bEvenIfReadOnly = true) const; bool Delete(bool bEvenIfReadOnly = true) const;

View File

@ -1,5 +1,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "SettingsType-SelectedDirectory.h" #include "SettingsType-SelectedDirectory.h"
#include <Common/path.h>
CSettingTypeSelectedDirectory::CSettingTypeSelectedDirectory(const char * Name, SettingID InitialDir, SettingID SelectedDir, SettingID UseSelected, SettingID NotifyChangeId) : CSettingTypeSelectedDirectory::CSettingTypeSelectedDirectory(const char * Name, SettingID InitialDir, SettingID SelectedDir, SettingID UseSelected, SettingID NotifyChangeId) :
m_Name(Name), m_Name(Name),
@ -41,7 +43,12 @@ bool CSettingTypeSelectedDirectory::Load(uint32_t /*Index*/, uint32_t & /*Value*
bool CSettingTypeSelectedDirectory::Load(uint32_t /*Index*/, std::string & Value) const bool CSettingTypeSelectedDirectory::Load(uint32_t /*Index*/, std::string & Value) const
{ {
SettingID DirSettingId = g_Settings->LoadBool(m_UseSelected) ? m_SelectedDir : m_InitialDir; SettingID DirSettingId = g_Settings->LoadBool(m_UseSelected) ? m_SelectedDir : m_InitialDir;
return g_Settings->LoadStringVal(DirSettingId, Value); if (g_Settings->LoadStringVal(DirSettingId, Value))
{
Value = (const char *)(CPath(Value).NormalizePath(CPath(CPath::MODULE_DIRECTORY)));
return true;
}
return false;
} }
// Return the default values // Return the default values