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
+27 -19
View File
@@ -324,31 +324,39 @@ void FilenameDB::AddFile( const CString &sPath, int size, int hash, void *priv )
} while( begin != end );
}
/* 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 )
{
if( dir == dirs.end() )
return;
FileSet *fs = dir->second;
/* Remove any stale dirp pointers. */
for( map<CString, FileSet *>::iterator it = dirs.begin(); it != dirs.end(); ++it )
{
FileSet *Clean = it->second;
for( set<File>::iterator f = Clean->files.begin(); f != Clean->files.end(); ++f )
{
File &ff = (File &) *f;
if( ff.dirp == fs )
ff.dirp = NULL;
}
}
delete fs;
dirs.erase( dir );
}
void FilenameDB::DelFile( const CString &sPath )
{
CString lower = sPath;
lower.MakeLower();
map<CString, FileSet *>::iterator fsi = dirs.find( lower );
if( fsi != dirs.end() )
{
FileSet *fs = fsi->second;
/* Remove any stale dirp pointers. */
for( map<CString, FileSet *>::iterator it = dirs.begin(); it != dirs.end(); ++it )
{
FileSet *Clean = it->second;
for( set<File>::iterator f = Clean->files.begin(); f != Clean->files.end(); ++f )
{
File &ff = (File &) *f;
if( ff.dirp == fs )
ff.dirp = NULL;
}
}
delete fs;
dirs.erase( fsi );
}
DelFileSet( fsi );
/* Delete sPath from its parent. */
CString Dir, Name;
+1
View File
@@ -81,6 +81,7 @@ protected:
const CString &beginning, const CString &containing, const CString &ending,
vector<CString> &out, bool bOnlyDirs);
void AddFileSet( CString sPath, FileSet *fs );
void DelFileSet( map<CString, FileSet *>::iterator dir );
/* The given path wasn't cached. Cache it. */
virtual void PopulateFileSet( FileSet &fs, const CString &sPath ) { }