GetRedirContents -> GetFileContents

This commit is contained in:
Glenn Maynard
2005-05-17 02:20:43 +00:00
parent 5c16cabf0d
commit 4e6d716027
5 changed files with 26 additions and 18 deletions
+2 -1
View File
@@ -238,7 +238,8 @@ try_again:
while( GetExtension(sPath) == "redir" )
{
CString sNewFileName = GetRedirContents(sPath);
CString sNewFileName;
GetFileContents( sPath, sNewFileName );
CString sRealPath;
FOREACHD_CONST( CString, data.vsDirSearchOrder, iter )
+17 -12
View File
@@ -663,7 +663,8 @@ CString DerefRedir(const CString &_path)
return path;
}
CString sNewFileName = GetRedirContents( path );
CString sNewFileName;
GetFileContents( path, sNewFileName );
/* Empty is invalid. */
if( sNewFileName == "" )
@@ -691,25 +692,29 @@ CString DerefRedir(const CString &_path)
RageException::Throw( "Circular redirect '%s'", path.c_str() );
}
/* XXX: This can be used to read one line from any file; rename it. */
CString GetRedirContents(const CString &path)
bool GetFileContents( const CString &sPath, CString &sOut )
{
/* Don't warn if the file doesn't exist, but do warn if it exists and fails to open. */
if( !IsAFile(sPath) )
return false;
RageFile file;
if( !file.Open(path) )
if( !file.Open(sPath) )
{
LOG->Warn( "GetRedirContents(%s): %s", path.c_str(), file.GetError().c_str() );
return "";
LOG->Warn( "GetFileContents(%s): %s", sPath.c_str(), file.GetError().c_str() );
return false;
}
CString sNewFileName;
if( file.GetLine( sNewFileName ) == -1 )
CString sData;
if( file.GetLine(sData) == -1 )
{
LOG->Warn( "GetRedirContents(%s): %s", path.c_str(), file.GetError().c_str() );
return "";
LOG->Warn( "GetFileContents(%s): %s", sPath.c_str(), file.GetError().c_str() );
return false;
}
StripCrnl(sNewFileName);
return sNewFileName;
StripCrnl( sData );
sOut = sData;
return true;
}
#if 1
+2 -2
View File
@@ -308,8 +308,8 @@ void TrimLeft(CString &str, const char *s = "\r\n\t ");
void TrimRight(CString &str, const char *s = "\r\n\t ");
void StripCrnl(CString &s);
CString DerefRedir(const CString &path);
CString GetRedirContents(const CString &path);
CString DerefRedir( const CString &sPath );
bool GetFileContents( const CString &sPath, CString &sOut );
class Regex {
void *reg;
+2 -1
View File
@@ -467,7 +467,8 @@ try_element_again:
}
else // bIsARedirect
{
CString sNewFileName = GetRedirContents(sPath);
CString sNewFileName;
GetFileContents( sPath, sNewFileName );
CString sNewClassName, sNewFile;
FileNameToClassAndElement(sNewFileName, sNewClassName, sNewFile);
+3 -2
View File
@@ -169,8 +169,9 @@ void Alsa9Buf::GetSoundCardDebugInfo()
if( DoesFileExist("/proc/asound/version") )
{
const CString ver = GetRedirContents("/proc/asound/version");
LOG->Info( "ALSA: %s", ver.c_str() );
CString sVersion;
GetFileContents( "/proc/asound/version", sVersion );
LOG->Info( "ALSA: %s", sVersion.c_str() );
}
InitializeErrorHandler();