This commit is contained in:
Glenn Maynard
2004-02-09 22:00:31 +00:00
parent dffd82879e
commit a9bbdc80d4
@@ -22,6 +22,13 @@
#include "MovieTexture_FFMpeg.h" #include "MovieTexture_FFMpeg.h"
#endif #endif
void ForceToAscii( CString &str )
{
for( unsigned i=0; i<str.size(); ++i )
if( str[i] < 0x20 || str[i] > 0x7E )
str[i] = '?';
}
bool RageMovieTexture::GetFourCC( CString fn, CString &handler, CString &type ) bool RageMovieTexture::GetFourCC( CString fn, CString &handler, CString &type )
{ {
CString ignore, ext; CString ignore, ext;
@@ -36,10 +43,13 @@ bool RageMovieTexture::GetFourCC( CString fn, CString &handler, CString &type )
} }
//Not very pretty but should do all the same error checking without iostream //Not very pretty but should do all the same error checking without iostream
#define HANDLE_ERROR(x) {error = x; goto errorLabel;} #define HANDLE_ERROR(x) { \
LOG->Warn( "Error reading %s: %s", fn.c_str(), x ); \
handler = type = ""; \
return false; \
}
RageFile file(fn); RageFile file(fn);
CString error("");
int i;
if( !file.IsOpen() ) if( !file.IsOpen() )
HANDLE_ERROR("Could not open file."); HANDLE_ERROR("Could not open file.");
@@ -48,23 +58,16 @@ bool RageMovieTexture::GetFourCC( CString fn, CString &handler, CString &type )
type = " "; type = " ";
if( file.Read((char *)type.c_str(), 4) != 4 ) if( file.Read((char *)type.c_str(), 4) != 4 )
HANDLE_ERROR("Could not read."); HANDLE_ERROR("Could not read.");
for (i=0; i<4; ++i) ForceToAscii( type );
if (type[i] < 0x20 || type[i] > 0x7E) type[i] = '?';
if ( !file.Seek(0xBC) ) if( file.Seek(0xBC) != 0xBC )
HANDLE_ERROR("Could not seek."); HANDLE_ERROR("Could not seek.");
handler = " "; handler = " ";
if( file.Read((char *)handler.c_str(), 4) != 4 ) if( file.Read((char *)handler.c_str(), 4) != 4 )
HANDLE_ERROR("Could not read."); HANDLE_ERROR("Could not read.");
for (i=0; i<4; ++i) ForceToAscii( handler );
if (handler[i] < 0x20 || handler[i] > 0x7E) handler[i] = '?';
return true; return true;
errorLabel:
LOG->Warn("Error on %s: %s.", fn.c_str(), error.c_str());
handler = type = "";
return false;
#undef HANDLE_ERROR #undef HANDLE_ERROR
} }