71 lines
1.9 KiB
C++
71 lines
1.9 KiB
C++
#include <nntp/rcvrlog.hpp>
|
|
#include <nntp/resource.hpp>
|
|
#include <common/stdio.hpp>
|
|
#include <common/diskinfo.hpp>
|
|
#include <fileio/fileio.hpp>
|
|
|
|
RecoverLog::RecoverLog(void)
|
|
: mStrRecoverLogPostFix(STRING_RECOVERLOGPOSTFIX)
|
|
{
|
|
}
|
|
|
|
RecoverLog::RecoverLog(const RecoverLog &someRecoverLog)
|
|
: mStrRecoverLogPostFix(STRING_RECOVERLOGPOSTFIX)
|
|
{ // private implementation
|
|
*this=someRecoverLog;
|
|
}
|
|
|
|
RecoverLog::~RecoverLog()
|
|
{
|
|
}
|
|
|
|
RecoverLog &RecoverLog::operator=(const RecoverLog &/*someRecoverLog*/)
|
|
{ // private implementation
|
|
return *this;
|
|
}
|
|
|
|
BOOL RecoverLog::haveLog(const String &strNewsGroup)
|
|
{
|
|
FileIO recoveryFile;
|
|
|
|
if(strNewsGroup.isNull())return FALSE;
|
|
recoveryFile.open(strNewsGroup+strRecoverLogPostFix(),FileIO::GenericRead,FileIO::FileShareRead,FileIO::OpenExisting,FileIO::Archive);
|
|
return recoveryFile.isOkay();
|
|
}
|
|
|
|
DWORD RecoverLog::getEntries(const String &strNewsGroup,Block<MsgID> &msgIDs)
|
|
{
|
|
FileIO recoveryFile;
|
|
MsgID msgID;
|
|
|
|
msgIDs.remove();
|
|
if(strNewsGroup.isNull())return FALSE;
|
|
recoveryFile.open(strNewsGroup+strRecoverLogPostFix(),FileIO::GenericRead,FileIO::FileShareRead,FileIO::OpenExisting,FileIO::Archive);
|
|
if(!recoveryFile.isOkay())return msgIDs.size();
|
|
while(recoveryFile.readLine(msgID))msgIDs.insert(&msgID);
|
|
recoveryFile.close();
|
|
return msgIDs.size();
|
|
}
|
|
|
|
BOOL RecoverLog::setEntries(const String &strNewsGroup,Block<String> &msgIDs)
|
|
{
|
|
FileIO recoveryFile;
|
|
|
|
if(strNewsGroup.isNull()||!msgIDs.size())return FALSE;
|
|
recoveryFile.open(strNewsGroup+strRecoverLogPostFix(),FileIO::GenericWrite,FileIO::FileShareRead,FileIO::OpenAlways,FileIO::Archive);
|
|
if(!recoveryFile.isOkay())return FALSE;
|
|
for(int itemIndex=0;itemIndex<msgIDs.size();itemIndex++)recoveryFile.writeLine(msgIDs[itemIndex]);
|
|
return TRUE;
|
|
}
|
|
|
|
void RecoverLog::removeLog(const String &strNewsGroup)
|
|
{
|
|
if(strNewsGroup.isNull())return;
|
|
::unlink(strNewsGroup+strRecoverLogPostFix());
|
|
}
|
|
|
|
const String &RecoverLog::strRecoverLogPostFix(void)const
|
|
{
|
|
return mStrRecoverLogPostFix;
|
|
}
|