From 5d2667add1879bcb9f556661f1f046905cecf466 Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Sun, 21 Jul 2024 06:24:47 -0700 Subject: [PATCH] Fix two small RageFile bugs 1) RageFileDriverDirect was failing to assign m_sRoot 2) Improve check if m_sRoot is empty 3) Fix a semi-broken logging method in RageFileManager --- src/RageFileDriverDirect.cpp | 4 ++-- src/RageFileManager.cpp | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/RageFileDriverDirect.cpp b/src/RageFileDriverDirect.cpp index f90093ecb7..0414aa65bc 100644 --- a/src/RageFileDriverDirect.cpp +++ b/src/RageFileDriverDirect.cpp @@ -40,7 +40,7 @@ static struct FileDriverEntry_DIRRO: public FileDriverEntry } const g_RegisterDriver2; RageFileDriverDirect::RageFileDriverDirect( const RString &sRoot ): - RageFileDriver( new DirectFilenameDB(sRoot) ) + RageFileDriver( new DirectFilenameDB(sRoot) ), m_sRoot(sRoot) { Remount( sRoot ); } @@ -158,7 +158,7 @@ bool RageFileDriverDirect::Move( const RString &sOldPath_, const RString &sNewPa bool RageFileDriverDirect::Remove( const RString &sPath_ ) { - if( m_sRoot == "(empty)" ) + if( m_sRoot.empty() || m_sRoot == "(empty)") { return false; } diff --git a/src/RageFileManager.cpp b/src/RageFileManager.cpp index 81f844e034..89755981d7 100644 --- a/src/RageFileManager.cpp +++ b/src/RageFileManager.cpp @@ -716,16 +716,13 @@ bool RageFileManager::Mount( const RString &sType, const RString &sRoot_, const RageFileDriver *pDriver = MakeFileDriver( sType, sRoot ); if( pDriver == nullptr ) { - CHECKPOINT_M( ssprintf("Can't mount unknown VFS type \"%s\", root \"%s\"", sType.c_str(), sRoot.c_str() ) ); - - if( LOG ) - LOG->Warn("Can't mount unknown VFS type \"%s\", root \"%s\"", sType.c_str(), sRoot.c_str() ); - else - fprintf( stderr, "Can't mount unknown VFS type \"%s\", root \"%s\"\n", sType.c_str(), sRoot.c_str() ); + const RString errorMsg = ssprintf("Can't mount unknown VFS type \"%s\", root \"%s\"", sType.c_str(), sRoot.c_str()); + CHECKPOINT_M( errorMsg ); + LOG->Warn( "%s", errorMsg.c_str() ); return false; } - CHECKPOINT_M("Driver %s successfully made."); + CHECKPOINT_M("Driver successfully made."); LoadedDriver *pLoadedDriver = new LoadedDriver; pLoadedDriver->m_pDriver = pDriver;