Remove implicit conversion operator from RString to const char*

This is required for the RString to std::string migration.

Mostly automated from https://github.com/aeubanks/rewriter/blob/main/c_str.cc, with some manual intervention required for fixing up `a + b.c_str()` to `(a + b).c_str()`.

Added some overloads for some common global functions like sm_crash to reduce the number of changes required here.
This commit is contained in:
Arthur Eubanks
2025-04-26 17:30:36 -07:00
committed by teejusb
parent 6a981ac5f7
commit ecfcb11a00
110 changed files with 458 additions and 426 deletions
+6 -6
View File
@@ -319,7 +319,7 @@ static RString ReadlinkRecursive( RString sPath )
{
sPath = dereferenced;
char derefPath[512];
ssize_t linkSize = readlink(sPath, derefPath, sizeof(derefPath));
ssize_t linkSize = readlink(sPath.c_str(), derefPath, sizeof(derefPath));
if ( linkSize != -1 && linkSize != sizeof(derefPath) )
{
dereferenced = RString( derefPath, linkSize );
@@ -376,7 +376,7 @@ static RString GetDirOfExecutable( RString argv0 )
split( path, ":", vPath );
for (RString &i : vPath)
{
if( access(i + "/" + argv0, X_OK|R_OK) )
if( access((i + "/" + argv0).c_str(), X_OK|R_OK) )
continue;
sPath = ExtractDirectory(ReadlinkRecursive(i + "/" + argv0));
break;
@@ -406,9 +406,9 @@ static void ChangeToDirOfExecutable( const RString &argv0 )
/* Set the CWD. Any effects of this is platform-specific; most files are read and
* written through RageFile. See also RageFileManager::RageFileManager. */
#if defined(_WINDOWS)
if( _chdir( RageFileManagerUtil::sDirOfExecutable + "/.." ) )
if( _chdir( (RageFileManagerUtil::sDirOfExecutable + "/..").c_str() ) )
#elif defined(UNIX)
if( chdir( RageFileManagerUtil::sDirOfExecutable + "/" ) )
if( chdir( (RageFileManagerUtil::sDirOfExecutable + "/").c_str() ) )
#elif defined(MACOSX)
/* If the basename is not MacOS, then we've likely been launched via the command line
* through a symlink. Assume this is the case and change to the dir of the symlink. */
@@ -706,7 +706,7 @@ bool RageFileManager::Mount( const RString &sType, const RString &sRoot_, const
const RString &sPaths = ssprintf( "\"%s\", \"%s\", \"%s\"", sType.c_str(), sRoot.c_str(), sMountPoint.c_str() );
CHECKPOINT_M( sPaths );
#if defined(DEBUG)
puts( sPaths );
puts( sPaths.c_str() );
#endif
// Unmount anything that was previously mounted here.
@@ -987,7 +987,7 @@ static bool PathUsesSlowFlush( const RString &sPath )
};
for( unsigned i = 0; i < ARRAYLEN(FlushPaths); ++i )
if( !strncmp( sPath, FlushPaths[i], strlen(FlushPaths[i]) ) )
if( !strncmp( sPath.c_str(), FlushPaths[i], strlen(FlushPaths[i]) ) )
return true;
return false;
}