|
From: Ermete G. <ex...@li...> - 2003-07-07 00:42:22
|
#include <utility/qa.h>
#include <paqmanager.h>
PAQManager::PAQManager()
{
}
PAQManager::~PAQManager()
{
}
//! This is intended to save a small amount of .PAQ files (less than 10 for example)
//! so the code is far from being optimized
PAQSolidFile * PAQManager::openPAQFile(std::string filename)
{
PAQSolidFile *newSolidFile;
std::string tempFilename;
// Search list of already opened files
InternalSolidFileVector::iterator it;
for(it = this->solidFileList.begin(); it<this->solidFileList.end(); it++){
it->first->getFilename(tempFilename);
if (tempFilename == filename)
return (PAQSolidFile*)(it->first);
}
// creates new file and add to internal list
newSolidFile = new PAQSolidFile(filename);
this->solidFileList.push_back( InternalSolidFileDescriptor(newSolidFile,1) );
return newSolidFile;
}
void PAQManager::closePAQFile(PAQSolidFile *solidFile)
{
std::string tempFilename,solidFilename;
solidFile->getFilename(solidFilename);
// Search internal list
InternalSolidFileVector::iterator it;
for(it = this->solidFileList.begin(); it<this->solidFileList.end(); it++)
{
it->first->getFilename(tempFilename);
// If file was already opened, decrement opencounter
if (tempFilename == solidFilename)
{
it->second--;
if (it->second > 0)
return;
}
}
delete solidFile;
} |