cleanup
This commit is contained in:
@@ -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,35 +43,31 @@ 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) { \
|
||||||
RageFile file(fn);
|
LOG->Warn( "Error reading %s: %s", fn.c_str(), x ); \
|
||||||
CString error("");
|
handler = type = ""; \
|
||||||
int i;
|
return false; \
|
||||||
|
}
|
||||||
|
|
||||||
if (!file.IsOpen())
|
RageFile file(fn);
|
||||||
|
|
||||||
|
if( !file.IsOpen() )
|
||||||
HANDLE_ERROR("Could not open file.");
|
HANDLE_ERROR("Could not open file.");
|
||||||
if ( !file.Seek(0x70) )
|
if( !file.Seek(0x70) )
|
||||||
HANDLE_ERROR("Could not seek.");
|
HANDLE_ERROR("Could not seek.");
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user