split out FilenameDB::DelFileSet
This commit is contained in:
@@ -324,31 +324,39 @@ void FilenameDB::AddFile( const CString &sPath, int size, int hash, void *priv )
|
|||||||
} while( begin != end );
|
} 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 )
|
void FilenameDB::DelFile( const CString &sPath )
|
||||||
{
|
{
|
||||||
CString lower = sPath;
|
CString lower = sPath;
|
||||||
lower.MakeLower();
|
lower.MakeLower();
|
||||||
|
|
||||||
map<CString, FileSet *>::iterator fsi = dirs.find( lower );
|
map<CString, FileSet *>::iterator fsi = dirs.find( lower );
|
||||||
if( fsi != dirs.end() )
|
DelFileSet( fsi );
|
||||||
{
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete sPath from its parent. */
|
/* Delete sPath from its parent. */
|
||||||
CString Dir, Name;
|
CString Dir, Name;
|
||||||
|
|||||||
@@ -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 ) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user