#include "global.h" #include #include #include "SongCacheIndex.h" #include "RageLog.h" #include "RageUtil.h" #include "song.h" SongCacheIndex *SONGINDEX; SongCacheIndex::SongCacheIndex() { mkdir("Cache", 0755); CacheIndex.SetPath( "Cache/index.cache" ); ReadCacheIndex(); } SongCacheIndex::~SongCacheIndex() { } static void EmptyDir( CString dir ) { ASSERT(dir[dir.size()-1] == '/'); CStringArray asCacheFileNames; GetDirListing( dir, asCacheFileNames ); for( unsigned i=0; iTrace( "Cache format is out of date. Deleting all cache files." ); EmptyDir( "Cache/" ); EmptyDir( "Cache/Banners/" ); CacheIndex.Reset(); } void SongCacheIndex::AddCacheIndex(const CString &path, unsigned hash) { CacheIndex.SetValueI( "Cache", "CacheVersion", FILE_CACHE_VERSION ); CacheIndex.SetValueU( "Cache", path, hash ); CacheIndex.WriteFile(); } unsigned SongCacheIndex::GetCacheHash( const CString &path ) const { unsigned iDirHash; CacheIndex.GetValueU( "Cache", path, iDirHash ); return iDirHash; }