split out FilenameDB::DelFileSet

This commit is contained in:
Glenn Maynard
2004-09-05 03:49:45 +00:00
parent 3da657bfc8
commit 99994a55cd
2 changed files with 28 additions and 19 deletions
+17 -9
View File
@@ -324,15 +324,15 @@ void FilenameDB::AddFile( const CString &sPath, int size, int hash, void *priv )
} while( begin != end ); } while( begin != end );
} }
void FilenameDB::DelFile( const CString &sPath ) /* Remove the given FileSet, and all dirp pointers to it. This means the cache has
* expired, not that the directory is necessarily gone; don't actually delete the file
* from the parent. */
void FilenameDB::DelFileSet( map<CString, FileSet *>::iterator dir )
{ {
CString lower = sPath; if( dir == dirs.end() )
lower.MakeLower(); return;
map<CString, FileSet *>::iterator fsi = dirs.find( lower ); FileSet *fs = dir->second;
if( fsi != dirs.end() )
{
FileSet *fs = fsi->second;
/* Remove any stale dirp pointers. */ /* Remove any stale dirp pointers. */
for( map<CString, FileSet *>::iterator it = dirs.begin(); it != dirs.end(); ++it ) for( map<CString, FileSet *>::iterator it = dirs.begin(); it != dirs.end(); ++it )
@@ -347,8 +347,16 @@ void FilenameDB::DelFile( const CString &sPath )
} }
delete fs; delete fs;
dirs.erase( fsi ); dirs.erase( dir );
} }
void FilenameDB::DelFile( const CString &sPath )
{
CString lower = sPath;
lower.MakeLower();
map<CString, FileSet *>::iterator fsi = dirs.find( lower );
DelFileSet( fsi );
/* Delete sPath from its parent. */ /* Delete sPath from its parent. */
CString Dir, Name; CString Dir, Name;
+1
View File
@@ -81,6 +81,7 @@ protected:
const CString &beginning, const CString &containing, const CString &ending, const CString &beginning, const CString &containing, const CString &ending,
vector<CString> &out, bool bOnlyDirs); vector<CString> &out, bool bOnlyDirs);
void AddFileSet( CString sPath, FileSet *fs ); void AddFileSet( CString sPath, FileSet *fs );
void DelFileSet( map<CString, FileSet *>::iterator dir );
/* The given path wasn't cached. Cache it. */ /* The given path wasn't cached. Cache it. */
virtual void PopulateFileSet( FileSet &fs, const CString &sPath ) { } virtual void PopulateFileSet( FileSet &fs, const CString &sPath ) { }