Allow storing private pointer in FilenameDB.

Add GetFile.
This commit is contained in:
Glenn Maynard
2003-12-10 04:58:47 +00:00
parent 8d6b19ad7a
commit 990dfb570a
2 changed files with 27 additions and 6 deletions
+21 -3
View File
@@ -243,7 +243,7 @@ void FilenameDB::AddFileSet( CString sPath, FileSet *fs )
/* Add the file or directory "sPath". sPath is a directory if it ends with
* a slash. */
void FilenameDB::AddFile( const CString &sPath, int size, int mtime )
void FilenameDB::AddFile( const CString &sPath, int size, int mtime, void *priv )
{
vector<CString> parts;
split( sPath, "/", parts, false );
@@ -269,8 +269,12 @@ void FilenameDB::AddFile( const CString &sPath, int size, int mtime )
if( fs.files.find( f ) == fs.files.end() )
{
f.dir = IsDir;
f.size = size;
f.mtime = mtime;
if( !IsDir )
{
f.size = size;
f.mtime = mtime;
f.priv = priv;
}
fs.files.insert( f );
}
IsDir = true;
@@ -286,6 +290,20 @@ void FilenameDB::FlushDirCache()
dirs.clear();
}
File *FilenameDB::GetFile( const CString &sPath )
{
CString Dir, Name;
SplitPath(sPath, Dir, Name);
FileSet &fs = GetFileSet( Dir );
set<File>::iterator i = fs.files.find( File(Name) );
if(i == fs.files.end())
return NULL;
return &*i;
}
void FilenameDB::GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo )