Files
itgmania212121/stepmania/src/SongCacheIndex.cpp
T

51 lines
1.1 KiB
C++
Raw Normal View History

2002-08-23 00:57:48 +00:00
#include "stdafx.h"
#include "SongCacheIndex.h"
#include "RageLog.h"
#include "RageUtil.h"
#include "Song.h"
SongCacheIndex *SONGINDEX;
SongCacheIndex::SongCacheIndex()
{
CacheIndex.SetPath( "Cache\\index.cache" );
ReadCacheIndex();
}
SongCacheIndex::~SongCacheIndex()
{
}
void SongCacheIndex::ReadCacheIndex()
{
CacheIndex.ReadFile(); // don't care if this fails
int iCacheVersion;
CacheIndex.GetValueI( "Cache", "CacheVersion", iCacheVersion );
if( iCacheVersion == FILE_CACHE_VERSION )
return; /* OK */
LOG->Trace( "Cache format is out of date. Deleting all cache files." );
CStringArray asCacheFileNames;
GetDirListing( "Cache/*.*", asCacheFileNames );
for( unsigned i=0; i<asCacheFileNames.size(); i++ )
DeleteFile( "Cache/" + asCacheFileNames[i] );
CacheIndex.Reset();
}
void SongCacheIndex::AddCacheIndex(const CString &path, int hash)
{
CacheIndex.SetValueI( "Cache", "CacheVersion", FILE_CACHE_VERSION );
CacheIndex.SetValueI( "Cache", path, hash );
CacheIndex.WriteFile();
}
int SongCacheIndex::GetCacheHash( const CString &path )
{
int iDirHash;
CacheIndex.GetValueI( "Cache", path, iDirHash );
return iDirHash;
}