Fix RageFile, use RageFile. Const fix in LyricsLoader.
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
#include "IniFile.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "SongManager.h"
|
||||
#include "RageFile.h"
|
||||
#include <time.h>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
Bookkeeper* BOOKKEEPER = NULL; // global and accessable from anywhere in our program
|
||||
@@ -92,14 +92,15 @@ void Bookkeeper::ReadFromDisk()
|
||||
ini.GetValue( "MachineStatistics", "TotalPlays", m_iTotalPlays );
|
||||
|
||||
// read dat
|
||||
FILE* fp = fopen( COINS_DAT, "r" );
|
||||
if( fp )
|
||||
{
|
||||
for( int i=0; i<DAYS_PER_YEAR; i++ )
|
||||
for( int j=0; j<HOURS_PER_DAY; j++ )
|
||||
fscanf( fp, "%d ", &m_iCoinsByHourForYear[i][j] );
|
||||
fclose( fp );
|
||||
}
|
||||
RageFile file(COINS_DAT, "r");
|
||||
if (file.IsOpen())
|
||||
{
|
||||
FILE *fp = file.GetFilePointer();
|
||||
|
||||
for (int i=0; i<DAYS_PER_YEAR; ++i)
|
||||
for (int j=0; j<HOURS_PER_DAY; ++j)
|
||||
fscanf(fp, "%d ", &m_iCoinsByHourForYear[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
void Bookkeeper::WriteToDisk()
|
||||
@@ -117,14 +118,16 @@ void Bookkeeper::WriteToDisk()
|
||||
ini.WriteFile();
|
||||
|
||||
// write dat
|
||||
FILE* fp = fopen( COINS_DAT, "w" );
|
||||
if( fp )
|
||||
{
|
||||
for( int i=0; i<DAYS_PER_YEAR; i++ )
|
||||
for( int j=0; j<HOURS_PER_DAY; j++ )
|
||||
fprintf( fp, "%d ", m_iCoinsByHourForYear[i][j] );
|
||||
fclose( fp );
|
||||
}
|
||||
RageFile file(COINS_DAT, "w");
|
||||
|
||||
if (file.IsOpen())
|
||||
{
|
||||
FILE *fp = file.GetFilePointer();
|
||||
|
||||
for (int i=0; i<DAYS_PER_YEAR; ++i)
|
||||
for (int j=0; j<HOURS_PER_DAY; ++j)
|
||||
fprintf(fp, "%d ", m_iCoinsByHourForYear[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
void Bookkeeper::UpdateLastSeenTime()
|
||||
|
||||
+14
-11
@@ -31,9 +31,10 @@
|
||||
#include "ProfileManager.h"
|
||||
#include "arch/arch.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "fstream"
|
||||
//#include "fstream"
|
||||
#include "Bookkeeper.h"
|
||||
#include "LightsManager.h"
|
||||
#include "RageFile.h"
|
||||
|
||||
#define DEFAULT_MODIFIERS THEME->GetMetric( "Common","DefaultModifiers" )
|
||||
|
||||
@@ -1007,18 +1008,20 @@ void GameState::StoreRankingName( PlayerNumber pn, CString name )
|
||||
// Filter swear words from name
|
||||
//
|
||||
name.MakeUpper();
|
||||
ifstream f;
|
||||
f.open( NAMES_BLACKLIST_FILE );
|
||||
if( f.good() )
|
||||
{
|
||||
CString sLine;
|
||||
while( getline(f,sLine) )
|
||||
RageFile file(NAMES_BLACKLIST_FILE);
|
||||
|
||||
if (file.IsOpen())
|
||||
{
|
||||
sLine.MakeUpper();
|
||||
if( name.Find(sLine) != -1 )
|
||||
name = "";
|
||||
CString line;
|
||||
|
||||
while (!file.AtEOF())
|
||||
{
|
||||
line = file.GetLine();
|
||||
line.MakeUpper();
|
||||
if (name.Find(line) != -1)
|
||||
name = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<RankingFeats> aFeats;
|
||||
GetRankingFeats( pn, aFeats );
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "RageUtil.h"
|
||||
#include "LyricsLoader.h"
|
||||
#include "ThemeManager.h"
|
||||
|
||||
#include "RageFile.h"
|
||||
#include <map>
|
||||
using namespace std;
|
||||
@@ -20,25 +19,25 @@ static int CompareLyricSegments(const LyricSegment &seg1, const LyricSegment &se
|
||||
return seg1.m_fStartTime < seg2.m_fStartTime;
|
||||
}
|
||||
|
||||
bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
|
||||
bool LyricsLoader::LoadFromLRCFile(const CString& sPath, Song& out)
|
||||
{
|
||||
LOG->Trace( "LyricsLoader::LoadFromLRCFile(%s)", sPath.c_str() );
|
||||
|
||||
ifstream input(sPath);
|
||||
if(input.bad())
|
||||
RageFile input(sPath, "r");
|
||||
|
||||
if (!input.IsOpen())
|
||||
{
|
||||
LOG->Warn( "Error opening file '%s' for reading.", sPath.c_str() );
|
||||
LOG->Warn("Error opening file '%s' for reading.", sPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
string line;
|
||||
|
||||
RageColor CurrentColor = LYRICS_DEFAULT_COLOR;
|
||||
|
||||
out.m_LyricSegments.clear();
|
||||
|
||||
while(input.good() && getline(input, line))
|
||||
while(input.GetError() == 0 && !input.AtEOF())
|
||||
{
|
||||
CString line = input.GetLine();
|
||||
if(!line.compare(0, 2, "//"))
|
||||
continue;
|
||||
|
||||
@@ -63,7 +62,7 @@ bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
|
||||
if(result != 3)
|
||||
{
|
||||
LOG->Trace( "The color value '%s' in '%s' is invalid.",
|
||||
sValueData.c_str(), sPath.c_str() );
|
||||
sValueData.c_str(), sPath.c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -73,7 +72,7 @@ bool LyricsLoader::LoadFromLRCFile( CString sPath, Song &out )
|
||||
|
||||
{
|
||||
/* If we've gotten this far, and no other statement caught
|
||||
* this value before this does, assume it's a time value. */
|
||||
* this value before this does, assume it's a time value. */
|
||||
|
||||
LyricSegment seg;
|
||||
seg.m_Color = CurrentColor;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
class LyricsLoader {
|
||||
public:
|
||||
bool LoadFromLRCFile( CString sPath, Song &out );
|
||||
bool LoadFromLRCFile( const CString& sPath, Song &out );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -155,13 +155,13 @@ bool BMSLoader::LoadFromBMSFile( const CString &sPath, Steps &out )
|
||||
pNoteData->SetNumTracks( MAX_NOTE_TRACKS );
|
||||
ResetTracksMagic();
|
||||
|
||||
ifstream file(sPath);
|
||||
if( file.bad() )
|
||||
RageException::Throw( "Failed to open %s for reading.", sPath.c_str() );
|
||||
RageFile file(sPath);
|
||||
|
||||
CString line;
|
||||
while( getline(file, line) ) // foreach line
|
||||
if (!file.IsOpen())
|
||||
RageException::Throw("Failed to open %s for reading.", sPath.c_str());
|
||||
while (!file.AtEOF())
|
||||
{
|
||||
CString line = file.GetLine();
|
||||
StripCrnl(line);
|
||||
CString value_name; // fill these in
|
||||
CString value_data;
|
||||
@@ -454,15 +454,14 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
|
||||
CString sPath = out.GetSongDir() + arrayBMSFileNames[0];
|
||||
|
||||
ifstream file(sPath);
|
||||
if( file.bad() )
|
||||
RageFile file(sPath);
|
||||
|
||||
if (!file.IsOpen())
|
||||
RageException::Throw( "Failed to open %s for reading.", sPath.c_str() );
|
||||
|
||||
CString line;
|
||||
while( getline(file, line) ) // foreach line
|
||||
while (!file.AtEOF())
|
||||
{
|
||||
CString line = file.GetLine();
|
||||
StripCrnl(line);
|
||||
|
||||
CString value_name; // fill these in
|
||||
CString value_data;
|
||||
|
||||
@@ -577,20 +576,6 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
break;
|
||||
}
|
||||
|
||||
// Let me just take a moment to express how frustrated I am with the new,
|
||||
// poorly-designed changes to the BMS format.
|
||||
//
|
||||
//
|
||||
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!
|
||||
//
|
||||
// Thank you.
|
||||
|
||||
// MD 10/26/03 - And allow me to add to that my opinion of the BMS format in general.
|
||||
//
|
||||
// ()*&@^*&^@$(*&^!@(*&^($*&^!#(*&@!&*#*#*@#*@#(*@(%@(*!
|
||||
//
|
||||
// end MD 10/26/03
|
||||
|
||||
case 8: { // indirect bpm
|
||||
// This is a very inefficient way to parse, but it doesn't matter much
|
||||
// because this is only parsed on the first run after the song is installed.
|
||||
@@ -599,13 +584,17 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
|
||||
|
||||
// open the song file again and and look for this tag's value
|
||||
ifstream file(sPath);
|
||||
if( file.bad() )
|
||||
RageException::Throw( "Failed to open %s for reading.", sPath.c_str() );
|
||||
/* I don't like this. I think we should just seek back to the beginning
|
||||
* rather than open the file again. However, I'm not changing the logic,
|
||||
* only the implementation. -- Steve
|
||||
*/
|
||||
RageFile file(sPath);//Why doesn't VC6 bitch here but it does with int??
|
||||
|
||||
CString line;
|
||||
while( getline(file, line) ) // foreach line
|
||||
if (!file.IsOpen())
|
||||
RageException::Throw( "Failed to open %s for reading.", sPath.c_str() );
|
||||
while (!file.AtEOF())
|
||||
{
|
||||
CString line = file.GetLine();
|
||||
StripCrnl(line);
|
||||
CString value_name; // fill these in
|
||||
CString value_data;
|
||||
@@ -628,9 +617,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
value_data.erase(0,iIndexOfSeparator+1);
|
||||
}
|
||||
else // no separator
|
||||
{
|
||||
value_name = line;
|
||||
}
|
||||
|
||||
if( 0==stricmp(value_name, sTagToLookFor) )
|
||||
{
|
||||
@@ -640,9 +627,7 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
}
|
||||
|
||||
if( fBPM == -1 ) // we didn't find the line we were looking for
|
||||
{
|
||||
LOG->Trace( "WARNING: Couldn't find tag '%s' in '%s'.", sTagToLookFor.c_str(), sPath.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
BPMSegment newSeg( NoteRowToBeat(iStepIndex), fBPM );
|
||||
@@ -661,13 +646,13 @@ bool BMSLoader::LoadFromDir( CString sDir, Song &out )
|
||||
|
||||
|
||||
// open the song file again and and look for this tag's value
|
||||
ifstream file(sPath);
|
||||
if( file.bad() )
|
||||
RageException::Throw( "Failed to open %s for reading.", sPath.c_str() );
|
||||
RageFile file(sPath);//Why doesn't VC6 bitch here but it does with int??
|
||||
|
||||
CString line;
|
||||
while( getline(file, line) ) // foreach line
|
||||
if (!file.IsOpen())
|
||||
RageException::Throw( "Failed to open %s for reading.", sPath.c_str() );
|
||||
while (!file.AtEOF())
|
||||
{
|
||||
CString line = file.GetLine();
|
||||
StripCrnl(line);
|
||||
CString value_name; // fill these in
|
||||
CString value_data;
|
||||
|
||||
@@ -46,6 +46,12 @@ void CollapsePath( CString &sPath )
|
||||
sPath = join( SLASH, as );
|
||||
}
|
||||
|
||||
RageFile::RageFile(const CString& path, const char *mode)
|
||||
{
|
||||
mFP = NULL;
|
||||
Open(path, mode);
|
||||
}
|
||||
|
||||
bool RageFile::Open(const CString& path, const char *mode)
|
||||
{
|
||||
Close();
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
||||
// call FixSlashes on any path that came from the user
|
||||
void FixSlashesInPlace( CString &sPath );
|
||||
@@ -31,7 +30,7 @@ private:
|
||||
|
||||
public:
|
||||
RageFile() : mPath("") { mFP = NULL; }
|
||||
RageFile(const CString& path, const char *mode = "r") { Open(path, mode); }
|
||||
RageFile(const CString& path, const char *mode = "r");
|
||||
~RageFile() { Close(); }
|
||||
|
||||
bool Open(const CString& path, const char *mode = "r");
|
||||
|
||||
@@ -508,14 +508,10 @@ CString DerefRedir(const CString &path)
|
||||
|
||||
CString GetRedirContents(const CString &path)
|
||||
{
|
||||
CString sNewFileName;
|
||||
{
|
||||
ifstream file(path);
|
||||
getline(file, sNewFileName);
|
||||
}
|
||||
RageFile file(path);
|
||||
CString sNewFileName = file.GetLine();
|
||||
|
||||
StripCrnl(sNewFileName);
|
||||
|
||||
return sNewFileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ SongManager* SONGMAN = NULL; // global and accessable from anywhere in our progr
|
||||
#define SONGS_DIR BASE_PATH "Songs" SLASH
|
||||
#define COURSES_DIR BASE_PATH "Courses" SLASH
|
||||
#define STATS_PATH BASE_PATH "stats.html"
|
||||
#define GROUP_SORT_COLOR_FILE BASE_PATH "Data" SLASH "GroupSortColor.ini"
|
||||
const CString CATEGORY_RANKING_FILE = BASE_PATH "Data" SLASH "CategoryRanking.dat";
|
||||
const CString MACHINE_STEPS_MEM_CARD_DATA = BASE_PATH "Data" SLASH "MachineStepsMemCardData.dat";
|
||||
const CString MACHINE_COURSE_MEM_CARD_DATA = BASE_PATH "Data" SLASH "MachineCourseMemCardData.dat";
|
||||
@@ -88,6 +89,36 @@ SongManager::SongManager( LoadingWindow *ld )
|
||||
|
||||
g_LastMetricUpdate.SetZero();
|
||||
UpdateMetrics();
|
||||
|
||||
IniFile gsc(GROUP_SORT_COLOR_FILE);
|
||||
const CString sortKey("Sort");
|
||||
const CString colorsKey("Colors");
|
||||
const IniFile::key *key;
|
||||
int i = 0;
|
||||
CString value;
|
||||
|
||||
if (!gsc.ReadFile())
|
||||
return;
|
||||
|
||||
gsc.GetValue(sortKey, "UnsortedAtEnd", m_bUnsortedAtEnd);
|
||||
while (gsc.GetValue(sortKey, ssprintf("Group%d", ++i), value))
|
||||
m_sSortedGroupNames.push_back(value);
|
||||
|
||||
key = gsc.GetKey(colorsKey);
|
||||
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
IniFile::key::const_iterator iter = key->begin();
|
||||
|
||||
while (iter != key->end())
|
||||
{
|
||||
RageColor c(1,1,1,1);
|
||||
sscanf((*iter).second, "%f,%f,%f,%f", &c.r, &c.g, &c.b, &c.a);
|
||||
m_mMappedGroupColors[(*iter).first] = c;
|
||||
LOG->Trace("Found color: %f.%f.%f.%f", c.r, c.g, c.b, c.a);
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
SongManager::~SongManager()
|
||||
@@ -346,60 +377,67 @@ void SongManager::FreeSongs()
|
||||
//
|
||||
// Helper function for reading/writing scores
|
||||
//
|
||||
bool FileRead( ifstream& f, CString& sOut )
|
||||
bool FileRead(RageFile& f, CString& sOut)
|
||||
{
|
||||
if( f.eof() )
|
||||
if (f.AtEOF())
|
||||
return false;
|
||||
getline(f, sOut);
|
||||
sOut = f.GetLine();
|
||||
return true;
|
||||
}
|
||||
bool FileRead( ifstream& f, int& iOut )
|
||||
|
||||
bool FileRead(RageFile& f, int& iOut)
|
||||
{
|
||||
CString s;
|
||||
if( !FileRead( f, s ) )
|
||||
if (!FileRead(f, s))
|
||||
return false;
|
||||
iOut = atoi( s );
|
||||
iOut = atoi(s);
|
||||
return true;
|
||||
}
|
||||
bool FileRead( ifstream& f, unsigned& uOut )
|
||||
|
||||
bool FileRead(RageFile& f, unsigned& uOut)
|
||||
{
|
||||
CString s;
|
||||
if( !FileRead( f, s ) )
|
||||
if (!FileRead(f, s))
|
||||
return false;
|
||||
uOut = atoi( s );
|
||||
uOut = atoi(s);
|
||||
return true;
|
||||
}
|
||||
bool FileRead( ifstream& f, float& fOut )
|
||||
|
||||
bool FileRead(RageFile& f, float& fOut)
|
||||
{
|
||||
CString s;
|
||||
if( !FileRead( f, s ) )
|
||||
if (!FileRead(f, s))
|
||||
return false;
|
||||
fOut = (float) atof( s );
|
||||
fOut = (float)atof(s);
|
||||
return true;
|
||||
}
|
||||
void FileWrite( ofstream& f, const CString& sWrite )
|
||||
|
||||
void FileWrite(RageFile& f, const CString& sWrite)
|
||||
{
|
||||
f << sWrite << "\n";
|
||||
f.PutString(sWrite + "\n");
|
||||
}
|
||||
void FileWrite( ofstream& f, int iWrite )
|
||||
|
||||
void FileWrite(RageFile& f, int iWrite)
|
||||
{
|
||||
f << iWrite << "\n";
|
||||
f.PutString(ssprintf("%d\n", iWrite));
|
||||
}
|
||||
void FileWrite( ofstream& f, size_t uWrite )
|
||||
|
||||
void FileWrite(RageFile& f, size_t uWrite)
|
||||
{
|
||||
f << uWrite << "\n";
|
||||
f.PutString(ssprintf("%lu\n", uWrite));
|
||||
}
|
||||
void FileWrite( ofstream& f, float fWrite )
|
||||
|
||||
void FileWrite(RageFile& f, float fWrite)
|
||||
{
|
||||
f << fWrite << "\n";
|
||||
f.PutString(ssprintf("%f\n", fWrite));
|
||||
}
|
||||
|
||||
#define WARN_AND_RETURN { LOG->Warn("Error parsing file '%s' at %s:%d",fn.c_str(),__FILE__,__LINE__); return; }
|
||||
|
||||
void SongManager::ReadStepsMemCardDataFromFile( CString fn, int mc )
|
||||
{
|
||||
ifstream f(fn);
|
||||
if( !f.good() )
|
||||
RageFile f(fn);
|
||||
if (!f.IsOpen() || f.GetError() != 0)
|
||||
WARN_AND_RETURN;
|
||||
|
||||
int version;
|
||||
@@ -493,8 +531,8 @@ void SongManager::ReadStepsMemCardDataFromFile( CString fn, int mc )
|
||||
|
||||
void SongManager::ReadCategoryRankingsFromFile( CString fn )
|
||||
{
|
||||
ifstream f(fn);
|
||||
if( !f.good() )
|
||||
RageFile f(fn);
|
||||
if (!f.IsOpen() || f.GetError() != 0)
|
||||
WARN_AND_RETURN;
|
||||
|
||||
int version;
|
||||
@@ -525,8 +563,8 @@ void SongManager::ReadCategoryRankingsFromFile( CString fn )
|
||||
|
||||
void SongManager::ReadCourseMemCardDataFromFile( CString fn, int mc )
|
||||
{
|
||||
ifstream f(fn);
|
||||
if( !f.good() )
|
||||
RageFile f(fn);
|
||||
if (!f.IsOpen() || f.GetError() != 0)
|
||||
WARN_AND_RETURN;
|
||||
|
||||
int version;
|
||||
@@ -680,8 +718,8 @@ void SongManager::SaveCategoryRankingsToFile( CString fn )
|
||||
{
|
||||
LOG->Trace("SongManager::SaveCategoryRankingsToFile");
|
||||
|
||||
ofstream f(fn);
|
||||
if( !f.good() )
|
||||
RageFile f(fn);
|
||||
if (!f.IsOpen() || f.GetError() != 0)
|
||||
return;
|
||||
|
||||
FileWrite( f, CATEGORY_RANKING_VERSION );
|
||||
@@ -708,8 +746,8 @@ void SongManager::SaveCourseMemCardDataToFile( CString fn, int mc )
|
||||
{
|
||||
LOG->Trace("SongManager::SaveCourseMemCardDataToFile");
|
||||
|
||||
ofstream f(fn);
|
||||
if( !f.good() )
|
||||
RageFile f(fn);
|
||||
if (!f.IsOpen() || f.GetError() != 0)
|
||||
return;
|
||||
|
||||
FileWrite( f, COURSE_MEM_CARD_DATA_VERSION );
|
||||
@@ -761,8 +799,8 @@ void SongManager::SaveStepsMemCardDataToFile( CString fn, int mc )
|
||||
{
|
||||
LOG->Trace("SongManager::SaveStepsMemCardDataToFile %s", fn.c_str());
|
||||
|
||||
ofstream f(fn);
|
||||
if( !f.good() )
|
||||
RageFile f(fn);
|
||||
if (!f.IsOpen() || f.GetError() != 0)
|
||||
return;
|
||||
|
||||
FileWrite( f, STEPS_MEM_CARD_DATA_VERSION );
|
||||
@@ -847,6 +885,11 @@ bool SongManager::DoesGroupExist( CString sGroupName )
|
||||
|
||||
RageColor SongManager::GetGroupColor( const CString &sGroupName )
|
||||
{
|
||||
const map<CString, RageColor>::const_iterator iter = m_mMappedGroupColors.find(sGroupName);
|
||||
|
||||
if (iter != m_mMappedGroupColors.end())
|
||||
return (*iter).second;
|
||||
|
||||
UpdateMetrics();
|
||||
|
||||
// search for the group index
|
||||
|
||||
@@ -101,18 +101,22 @@ TitleSubst::TitleSubst(const CString §ion)
|
||||
|
||||
void TitleSubst::Load(const CString &filename, const CString §ion)
|
||||
{
|
||||
ifstream f;
|
||||
f.open(filename);
|
||||
if(!f.good()) return;
|
||||
RageFile f(filename);
|
||||
|
||||
if (!f.IsOpen() || f.GetError() != 0)
|
||||
return;
|
||||
|
||||
CString CurrentSection;
|
||||
TitleTrans tr;
|
||||
|
||||
while(!f.eof())
|
||||
while (!f.AtEOF())
|
||||
{
|
||||
CString line;
|
||||
if(!getline(f, line)) continue;
|
||||
|
||||
CString line = f.GetLine();
|
||||
if (f.GetError() != 0)
|
||||
{
|
||||
clearerr(f.GetFilePointer());
|
||||
continue;
|
||||
}
|
||||
if(line.size() > 0 && utf8_get_char(line.c_str()) == 0xFEFF)
|
||||
{
|
||||
/* Annoying header that Windows puts on UTF-8 plaintext
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "RageLog.h"
|
||||
#include "MovieTexture_Null.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageFile.h"
|
||||
|
||||
/* _WINDOWS is Windows only, where _WIN32 is Windows and Xbox, I think. Does this
|
||||
* work on the Xbox? -glenn */
|
||||
@@ -21,7 +22,6 @@
|
||||
#include "MovieTexture_FFMpeg.h"
|
||||
#endif
|
||||
|
||||
#include "RageFile.h"
|
||||
bool RageMovieTexture::GetFourCC( CString fn, CString &handler, CString &type )
|
||||
{
|
||||
CString ignore, ext;
|
||||
@@ -35,32 +35,37 @@ bool RageMovieTexture::GetFourCC( CString fn, CString &handler, CString &type )
|
||||
return true;
|
||||
}
|
||||
|
||||
ifstream f;
|
||||
f.exceptions( ifstream::eofbit | ifstream::failbit | ifstream::badbit );
|
||||
//Not very pretty but should do all the same error checking without iostream
|
||||
#define HANDLE_ERROR(x) {error = x; goto errorLabel;}
|
||||
RageFile file(fn);
|
||||
CString error("");
|
||||
int i;
|
||||
|
||||
try {
|
||||
f.open(fn);
|
||||
if (!file.IsOpen())
|
||||
HANDLE_ERROR("Could not open file.");
|
||||
if (!file.Seek(0x70, SEEK_SET))
|
||||
HANDLE_ERROR("Could not seek.");
|
||||
type = " ";
|
||||
if (file.Read((char *)type.c_str(), 4) != 4)
|
||||
HANDLE_ERROR("Could not read.");
|
||||
for (i=0; i<4; ++i)
|
||||
if (type[i] < 0x20 || type[i] > 0x7E) type[i] = '?';
|
||||
|
||||
f.seekg( 0x70, ios_base::beg );
|
||||
type = " ";
|
||||
f.read((char *) type.c_str(), 4);
|
||||
int i;
|
||||
for( i = 0; i < 4; ++i)
|
||||
if(type[i] < 0x20 || type[i] > 0x7E) type[i] = '?';
|
||||
|
||||
f.seekg( 0xBC, ios_base::beg );
|
||||
|
||||
handler = " ";
|
||||
f.read((char *) handler.c_str(), 4);
|
||||
for(i = 0; i < 4; ++i)
|
||||
if(handler[i] < 0x20 || handler[i] > 0x7E) handler[i] = '?';
|
||||
} catch(ifstream::failure e) {
|
||||
LOG->Warn("error on %s: %s", fn.c_str(), e.what() );
|
||||
handler = type = "";
|
||||
return false;
|
||||
}
|
||||
if (!file.Seek(0xBC, SEEK_SET))
|
||||
HANDLE_ERROR("Could not seek.");
|
||||
handler = " ";
|
||||
if (file.Read((char *)handler.c_str(), 4) != 4)
|
||||
HANDLE_ERROR("Could not read.");
|
||||
for (i=0; i<4; ++i)
|
||||
if (handler[i] < 0x20 || handler[i] > 0x7E) handler[i] = '?';
|
||||
|
||||
return true;
|
||||
|
||||
errorLabel:
|
||||
LOG->Warn("Error on %s: %s.", fn.c_str(), error.c_str());
|
||||
handler = type = "";
|
||||
return false;
|
||||
#undef HANDLE_ERROR
|
||||
}
|
||||
|
||||
static void DumpAVIDebugInfo( CString fn )
|
||||
|
||||
Reference in New Issue
Block a user