no message
This commit is contained in:
@@ -108,4 +108,84 @@ void RageTexture::GetFrameDimensionsFromFileName( CString sPath, int* piFramesWi
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
CString RageTexture::GetCacheFilePath()
|
||||
{
|
||||
ULONG hash = GetHashForString( m_sFilePath );
|
||||
return ssprintf( "Cache\\%u.texinfo", hash );
|
||||
}
|
||||
|
||||
const int FILE_CACHE_VERSION = 10; // increment this when the cache file format changes
|
||||
|
||||
void RageTexture::SaveToCacheFile()
|
||||
{
|
||||
LOG->WriteLine( "RageBitmapTexture::SaveToCacheFile()" );
|
||||
|
||||
CString sCacheFilePath = GetCacheFilePath();
|
||||
|
||||
FILE* file = fopen( sCacheFilePath, "w" );
|
||||
ASSERT( file != NULL );
|
||||
if( file == NULL )
|
||||
return;
|
||||
|
||||
WriteIntToFile( file, FILE_CACHE_VERSION );
|
||||
WriteUlongToFile( file, GetHashForFile(m_sFilePath) );
|
||||
WriteStringToFile( file, m_sFilePath );
|
||||
WriteIntToFile( file, m_iSourceWidth );
|
||||
WriteIntToFile( file, m_iSourceHeight );
|
||||
WriteIntToFile( file, m_iTextureWidth );
|
||||
WriteIntToFile( file, m_iTextureHeight );
|
||||
WriteIntToFile( file, m_iImageWidth );
|
||||
WriteIntToFile( file, m_iImageHeight );
|
||||
WriteIntToFile( file, m_iFramesWide );
|
||||
WriteIntToFile( file, m_iFramesHigh );
|
||||
WriteIntToFile( file, m_TextureFormat );
|
||||
|
||||
fclose( file );
|
||||
}
|
||||
|
||||
bool RageTexture::LoadFromCacheFile()
|
||||
{
|
||||
LOG->WriteLine( "Song::LoadFromCacheFile()" );
|
||||
|
||||
CString sCacheFilePath = GetCacheFilePath();
|
||||
|
||||
LOG->WriteLine( "cache file is '%s'.", sCacheFilePath );
|
||||
|
||||
FILE* file = fopen( sCacheFilePath, "r" );
|
||||
if( file == NULL )
|
||||
return false;
|
||||
|
||||
int iCacheVersion;
|
||||
ReadIntFromFile( file, iCacheVersion );
|
||||
if( iCacheVersion != FILE_CACHE_VERSION )
|
||||
{
|
||||
LOG->WriteLine( "Cache file versions don't match '%s'.", sCacheFilePath );
|
||||
fclose( file );
|
||||
return false;
|
||||
}
|
||||
|
||||
ULONG hash;
|
||||
ReadUlongFromFile( file, hash );
|
||||
if( hash != GetHashForFile(m_sFilePath) )
|
||||
{
|
||||
LOG->WriteLine( "Cache file is out of date.", sCacheFilePath );
|
||||
fclose( file );
|
||||
return false;
|
||||
}
|
||||
|
||||
ReadStringFromFile( file, m_sFilePath );
|
||||
ReadIntFromFile( file, m_iSourceWidth );
|
||||
ReadIntFromFile( file, m_iSourceHeight );
|
||||
ReadIntFromFile( file, m_iTextureWidth );
|
||||
ReadIntFromFile( file, m_iTextureHeight );
|
||||
ReadIntFromFile( file, m_iImageWidth );
|
||||
ReadIntFromFile( file, m_iImageHeight );
|
||||
ReadIntFromFile( file, m_iFramesWide );
|
||||
ReadIntFromFile( file, m_iFramesHigh );
|
||||
ReadIntFromFile( file, (int&)m_TextureFormat );
|
||||
|
||||
fclose( file );
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user