get rid of CStdioFile

This commit is contained in:
Glenn Maynard
2002-10-31 03:54:50 +00:00
parent 31fa2adaa4
commit 7d46004e54
4 changed files with 65 additions and 74 deletions
+7 -16
View File
@@ -12,11 +12,8 @@
*/
#include "IniFile.h"
/////////////////////////////////////////////////////////////////////
// Construction/Destruction
/////////////////////////////////////////////////////////////////////
#include <fstream>
using namespace std;
//constructor, can specify pathname here instead of using SetPath later
IniFile::IniFile(CString inipath)
@@ -30,10 +27,6 @@ IniFile::~IniFile()
}
/////////////////////////////////////////////////////////////////////
// Public Functions
/////////////////////////////////////////////////////////////////////
// sets path of ini file to read and write from
void IniFile::SetPath(CString newpath)
{
@@ -44,19 +37,18 @@ void IniFile::SetPath(CString newpath)
// returns true if successful, false otherwise
bool IniFile::ReadFile()
{
CStdioFile file;
CFileStatus status;
if (!file.GetStatus(path,status))
return 0;
if (!file.Open(path, CFile::modeRead))
ifstream file(path);
if (file.bad())
{
error = "Unable to open ini file.";
return 0;
}
CString keyname, valuename, value;
CString temp;
CString line;
while (file.ReadString(line))
while (getline(file, line))
{
if (line == "")
continue;
@@ -78,7 +70,6 @@ bool IniFile::ReadFile()
}
}
}
file.Close();
return 1;
}
+13 -15
View File
@@ -8,6 +8,7 @@
#include "RageLog.h"
#include "GameManager.h"
#include "RageException.h"
#include <fstream>
// BMS encoding: tap-hold
// 4&8panel: Player1 Player2
@@ -67,12 +68,12 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Notes &out )
NoteData* pNoteData = new NoteData;
pNoteData->m_iNumTracks = MAX_NOTE_TRACKS;
CStdioFile file;
if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) )
ifstream file(sPath);
if( file.bad() )
throw RageException( "Failed to open %s for reading.", sPath.GetString() );
CString line;
while( file.ReadString(line) ) // foreach line
while( getline(file, line) ) // foreach line
{
CString value_name; // fill these in
CString value_data;
@@ -276,12 +277,12 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
CString sPath = out.m_sSongDir + arrayBMSFileNames[0];
CStdioFile file;
if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) )
ifstream file(sPath);
if( file.bad() )
throw RageException( "Failed to open %s for reading.", sPath.GetString() );
CString line;
while( file.ReadString(line) ) // foreach line
while( getline(file, line) ) // foreach line
{
CString value_name; // fill these in
CString value_data;
@@ -413,12 +414,12 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
// open the song file again and and look for this tag's value
CStdioFile file;
if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) )
ifstream file(sPath);
if( file.bad() )
throw RageException( "Failed to open %s for reading.", sPath.GetString() );
CString line;
while( file.ReadString(line) ) // foreach line
while( getline(file, line) ) // foreach line
{
CString value_name; // fill these in
CString value_data;
@@ -463,7 +464,6 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
LOG->Trace( "Inserting new BPM change at beat %f, BPM %f", newSeg.m_fStartBeat, newSeg.m_fBPM );
}
file.Close();
break;
}
case 9: { // stop
@@ -475,12 +475,12 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
// open the song file again and and look for this tag's value
CStdioFile file;
if( !file.Open( sPath, CFile::modeRead|CFile::shareDenyNone ) )
ifstream file(sPath);
if( file.bad() )
throw RageException( "Failed to open %s for reading.", sPath.GetString() );
CString line;
while( file.ReadString(line) ) // foreach line
while( getline(file, line) ) // foreach line
{
CString value_name; // fill these in
CString value_data;
@@ -540,7 +540,6 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
LOG->Trace( "Inserting new Freeze at beat %f, secs %f", newSeg.m_fStartBeat, newSeg.m_fStopSeconds );
}
file.Close();
break;
}
}
@@ -552,7 +551,6 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
LOG->Trace( "There is a BPM change at beat %f, BPM %f, index %d",
out.m_BPMSegments[i].m_fStartBeat, out.m_BPMSegments[i].m_fBPM, i );
file.Close();
return true;
}
+1 -1
View File
@@ -65,7 +65,7 @@ CString NotesWriterDWI::NotesToDWIString( char cNoteCol1, char cNoteCol2, char c
if( cHold != '0' )
return ssprintf( "%c!%c", cShow, cHold );
else
return cShow;
return ssprintf( "%c", cShow );
}
CString NotesWriterDWI::NotesToDWIString( char cNoteCol1, char cNoteCol2, char cNoteCol3, char cNoteCol4 )
+9 -7
View File
@@ -20,6 +20,8 @@
#include "IniFile.h"
#include "RageTimer.h"
#include <fstream>
using namespace std;
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
@@ -127,10 +129,9 @@ try_element_again:
GetDirListing( sCurrentThemeDir + sAssetCategory+"\\"+sFileName + "*.redir", asPossibleElementFilePaths, false, true );
if( !asPossibleElementFilePaths.empty() )
{
CStdioFile file;
file.Open( asPossibleElementFilePaths[0], CFile::modeRead );
ifstream file(asPossibleElementFilePaths[0]);
CString sLine;
file.ReadString( sLine );
getline(file, sLine);
}
@@ -196,13 +197,14 @@ try_element_again:
CString sDir, sFName, sExt;
splitrelpath( sRedirFilePath, sDir, sFName, sExt );
CStdioFile file;
file.Open( sRedirFilePath, CFile::modeRead );
CString sNewFileName;
file.ReadString( sNewFileName );
{
ifstream file(sRedirFilePath);
getline(file, sNewFileName );
// CString sNewFilePath = sDir+"\\"+sNewFileName; // This is what it used to be, FONT redirs were getting extra slashes
// at the start of their file names, so I took out this extra slash - Andy.
file.Close();
}
CString sNewFilePath = sDir+sNewFileName;
if( sNewFileName == "" || !DoesFileExist(sNewFilePath) )
{