本文整理汇总了C++中CKnownFile::IsPartFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CKnownFile::IsPartFile方法的具体用法?C++ CKnownFile::IsPartFile怎么用?C++ CKnownFile::IsPartFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKnownFile
的用法示例。
在下文中一共展示了CKnownFile::IsPartFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeleteUpdate
BOOL CUpdateInfo::DeleteUpdate(CString hash)
{
uchar UpdateHash[16];
CPartFile* pPartFile;
if(!strmd4(hash,UpdateHash))
{
return FALSE;
}
CKnownFile* file = CGlobalVariable::sharedfiles->GetFileByID(UpdateHash);
try
{
//共享列表中是否有
if(file)
{
if(file->IsPartFile())
{
//共享列表有,但未下载完,移除
pPartFile = DYNAMIC_DOWNCAST(CPartFile,file);
if( pPartFile )
{
pPartFile->DeleteFile();
}
}
else
{
//共享列表有,已经下载完成未安装,移除
DeleteFile(file->GetFilePath());
theApp.emuledlg->sharedfileswnd->sharedfilesctrl.RemoveFile(file);
CGlobalVariable::sharedfiles->RemoveFile(file);
}
}
if ((pPartFile = CGlobalVariable::downloadqueue->GetFileByID(UpdateHash)) != NULL)
{
//共享列表没有,但未下载完,移除
pPartFile->DeleteFile();
}
}
catch (CException* e)
{
e->Delete();
return FALSE;
}
return FALSE;
}
示例2: Run
int CAICHSyncThread::Run()
{
if ( !theApp.emuledlg->IsRunning() )
return 0;
// we collect all masterhashs which we find in the known2.met and store them in a list
CList<CAICHHash> liKnown2Hashs;
CString fullpath=thePrefs.GetConfigDir();
fullpath.Append(KNOWN2_MET_FILENAME);
CSafeFile file;
CFileException fexp;
uint32 nLastVerifiedPos = 0;
if (!file.Open(fullpath,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate|CFile::osSequentialScan|CFile::typeBinary|CFile::shareDenyNone, &fexp)){
if (fexp.m_cause != CFileException::fileNotFound){
CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file"));
TCHAR szError[MAX_CFEXP_ERRORMSG];
if (fexp.GetErrorMessage(szError, ARRSIZE(szError))){
strError += _T(" - ");
strError += szError;
}
LogError(LOG_STATUSBAR, _T("%s"), strError);
}
return false;
}
try {
//setvbuf(file.m_pStream, NULL, _IOFBF, 16384);
uint32 nExistingSize = file.GetLength();
uint16 nHashCount;
while (file.GetPosition() < nExistingSize){
liKnown2Hashs.AddTail(CAICHHash(&file));
nHashCount = file.ReadUInt16();
if (file.GetPosition() + nHashCount*HASHSIZE > nExistingSize){
AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName());
}
// skip the rest of this hashset
file.Seek(nHashCount*HASHSIZE, CFile::current);
nLastVerifiedPos = file.GetPosition();
}
}
catch(CFileException* error){
if (error->m_cause == CFileException::endOfFile){
LogError(LOG_STATUSBAR,GetResString(IDS_ERR_SERVERMET_BAD));
// truncate the file to the size to the last verified valid pos
try{
file.SetLength(nLastVerifiedPos);
}
catch(CFileException* error2){
error2->Delete();
}
}
else{
TCHAR buffer[MAX_CFEXP_ERRORMSG];
error->GetErrorMessage(buffer, ARRSIZE(buffer));
LogError(LOG_STATUSBAR,GetResString(IDS_ERR_SERVERMET_UNKNOWN),buffer);
}
error->Delete();
return false;
}
file.Close();
// now we check that all files which are in the sharedfilelist have a corresponding hash in out list
// those how don'T are added to the hashinglist
for (uint32 i = 0; i < theApp.sharedfiles->GetCount(); i++){
CKnownFile* pCurFile = theApp.sharedfiles->GetFileByIndex(i);
if (pCurFile != NULL && !pCurFile->IsPartFile() ){
if (theApp.emuledlg==NULL || !theApp.emuledlg->IsRunning()) // in case of shutdown while still hashing
return 0;
if (pCurFile->GetAICHHashset()->GetStatus() == AICH_HASHSETCOMPLETE){
bool bFound = false;
for (POSITION pos = liKnown2Hashs.GetHeadPosition();pos != 0;)
{
if (liKnown2Hashs.GetNext(pos) == pCurFile->GetAICHHashset()->GetMasterHash()){
bFound = true;
#ifdef _DEBUG
// in debugmode we load and verify all hashsets
ASSERT( pCurFile->GetAICHHashset()->LoadHashSet() );
// pCurFile->GetAICHHashset()->DbgTest();
pCurFile->GetAICHHashset()->FreeHashSet();
#endif
break;
}
}
if (bFound) // hashset is available, everything fine with this file
continue;
}
pCurFile->GetAICHHashset()->SetStatus(AICH_ERROR);
m_liToHash.AddTail(pCurFile);
}
}
// warn the user if he just upgraded
if (thePrefs.IsFirstStart() && !m_liToHash.IsEmpty()){
LogWarning(GetResString(IDS_AICH_WARNUSER));
}
if (!m_liToHash.IsEmpty()){
AddLogLine(true, GetResString(IDS_AICH_SYNCTOTAL), m_liToHash.GetCount() ); // I18n: ThreadSafeLog
theApp.emuledlg->sharedfileswnd->sharedfilesctrl.SetAICHHashing(m_liToHash.GetCount());
// let first all normal hashing be done before starting out synchashing
CSingleLock sLock1(&theApp.hashing_mut); // only one filehash at a time
while (theApp.sharedfiles->GetHashingCount() != 0){
//.........这里部分代码省略.........
示例3: OnDrawItem
//.........这里部分代码省略.........
textBuffer = file->GetFileName().GetPrintable();
if (file->GetFileRating() || file->GetFileComment().Length()) {
int image = Client_CommentOnly_Smiley;
if (file->GetFileRating()) {
image = Client_InvalidRating_Smiley + file->GetFileRating() - 1;
}
wxASSERT(image >= Client_InvalidRating_Smiley);
wxASSERT(image <= Client_CommentOnly_Smiley);
int imgWidth = 16;
theApp->amuledlg->m_imagelist.Draw(image, *dc, columnRect.x,
columnRect.y + 1, wxIMAGELIST_DRAW_TRANSPARENT);
// Move the text to the right
columnRect.x += (imgWidth + 4);
}
break;
case ID_SHARED_COL_SIZE:
textBuffer = CastItoXBytes(file->GetFileSize());
break;
case ID_SHARED_COL_TYPE:
textBuffer = GetFiletypeByName(file->GetFileName());
break;
case ID_SHARED_COL_PRIO:
textBuffer = PriorityToStr(file->GetUpPriority(), file->IsAutoUpPriority());
break;
case ID_SHARED_COL_ID:
textBuffer = file->GetFileHash().Encode();
break;
case ID_SHARED_COL_REQ:
textBuffer = CFormat(wxT("%u (%u)"))
% file->statistic.GetRequests()
% file->statistic.GetAllTimeRequests();
break;
case ID_SHARED_COL_AREQ:
textBuffer = CFormat(wxT("%u (%u)"))
% file->statistic.GetAccepts()
% file->statistic.GetAllTimeAccepts();
break;
case ID_SHARED_COL_TRA:
textBuffer = CastItoXBytes(file->statistic.GetTransferred())
+ wxT(" (") + CastItoXBytes(file->statistic.GetAllTimeTransferred()) + wxT(")");
break;
case ID_SHARED_COL_RTIO:
textBuffer = CFormat(wxT("%.2f")) % ((double)file->statistic.GetAllTimeTransferred() / file->GetFileSize());
break;
case ID_SHARED_COL_PART:
if ( file->GetPartCount() ) {
wxRect barRect(columnRect.x, columnRect. y + 1,
columnRect.width, columnRect.height - 2);
DrawAvailabilityBar(file, dc, barRect);
}
break;
case ID_SHARED_COL_CMPL:
if ( file->m_nCompleteSourcesCountLo == 0 ) {
if ( file->m_nCompleteSourcesCountHi ) {
textBuffer = CFormat(wxT("< %u")) % file->m_nCompleteSourcesCountHi;
} else {
textBuffer = wxT("0");
}
} else if (file->m_nCompleteSourcesCountLo == file->m_nCompleteSourcesCountHi) {
textBuffer = CFormat(wxT("%u")) % file->m_nCompleteSourcesCountLo;
} else {
textBuffer = CFormat(wxT("%u - %u")) % file->m_nCompleteSourcesCountLo % file->m_nCompleteSourcesCountHi;
}
break;
case ID_SHARED_COL_PATH:
if ( file->IsPartFile() ) {
textBuffer = _("[PartFile]");
} else {
textBuffer = file->GetFilePath().GetPrintable();
}
}
if (!textBuffer.IsEmpty()) {
dc->DrawText(textBuffer, columnRect.x, columnRect.y + textVOffset);
}
}
// Move to the next column
columnLeft += columnWidth;
}
}
示例4: ClearUpdateHistory
BOOL CUpdateInfo::ClearUpdateHistory(const uchar * hashkey)//清除历史升级任务
{
for (int i = 0; i < CGlobalVariable::sharedfiles->GetCount(); i++)
{
CKnownFile* file = CGlobalVariable::sharedfiles->GetFileByIndex(i);
CPartFile* pPartFile;
try
{
//共享列表中是否有
if(file)
{
if ( IsUpdateTask( file->GetFilePath() ) && file->GetFileHash() != hashkey )
{
if(file->IsPartFile())
{
//共享列表有,但未下载完,移除
pPartFile = DYNAMIC_DOWNCAST(CPartFile,file);
if( pPartFile )
{
pPartFile->DeleteFile();
}
}
else
{
//共享列表有,已经下载完成未安装,移除
DeleteFile(file->GetFilePath());
theApp.emuledlg->sharedfileswnd->sharedfilesctrl.RemoveFile(file);
CGlobalVariable::sharedfiles->RemoveFile(file);
CGlobalVariable::filemgr.RemoveFileItem(file);
}
}
else
continue;
}
}
catch (CException* e)
{
e->Delete();
//return FALSE;
}
}
for (int i = 0; i < CGlobalVariable::downloadqueue->GetFileCount(); i++)
{
CPartFile* pFile = CGlobalVariable::downloadqueue->GetFileByIndex(i);
try
{
if (pFile)
{
if ( IsUpdateTask( pFile->GetFilePath() ) && pFile->GetFileHash() != hashkey )
{
//共享列表没有,但未下载完,移除
pFile->DeleteFile();
}
}
}
catch (CException* e)
{
e->Delete();
//return FALSE;
}
}
return TRUE;
}
示例5: Run
int CAICHSyncThread::Run()
{
if ( !theApp.emuledlg->IsRunning() )
return 0;
// we need to keep a lock on this file while the thread is running
CSingleLock lockKnown2Met(&CAICHHashSet::m_mutKnown2File);
lockKnown2Met.Lock();
// we collect all masterhashs which we find in the known2.met and store them in a list
CList<CAICHHash> liKnown2Hashs;
CString fullpath=thePrefs.GetConfigDir();
fullpath.Append(KNOWN2_MET_FILENAME);
CSafeFile file;
CFileException fexp;
uint32 nLastVerifiedPos = 0;
if (!file.Open(fullpath,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate|CFile::osSequentialScan|CFile::typeBinary|CFile::shareDenyNone, &fexp)){
if (fexp.m_cause != CFileException::fileNotFound){
CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file"));
TCHAR szError[MAX_CFEXP_ERRORMSG];
if (fexp.GetErrorMessage(szError, ARRSIZE(szError))){
strError += _T(" - ");
strError += szError;
}
LogError(LOG_STATUSBAR, _T("%s"), strError);
}
return false;
}
try {
//setvbuf(file.m_pStream, NULL, _IOFBF, 16384);
uint32 nExistingSize = (UINT)file.GetLength();
uint16 nHashCount;
while (file.GetPosition() < nExistingSize){
liKnown2Hashs.AddTail(CAICHHash(&file));
nHashCount = file.ReadUInt16();
if (file.GetPosition() + nHashCount*CAICHHash::GetHashSize() > nExistingSize){
AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName());
}
// skip the rest of this hashset
file.Seek(nHashCount*CAICHHash::GetHashSize(), CFile::current);
nLastVerifiedPos = (UINT)file.GetPosition();
}
}
catch(CFileException* error){
if (error->m_cause == CFileException::endOfFile){
LogError(LOG_STATUSBAR,GetResString(IDS_ERR_SERVERMET_BAD));
// truncate the file to the size to the last verified valid pos
try{
file.SetLength(nLastVerifiedPos);
}
catch(CFileException* error2){
error2->Delete();
}
}
else{
TCHAR buffer[MAX_CFEXP_ERRORMSG];
error->GetErrorMessage(buffer, ARRSIZE(buffer));
LogError(LOG_STATUSBAR,GetResString(IDS_ERR_SERVERMET_UNKNOWN),buffer);
}
error->Delete();
return false;
}
// now we check that all files which are in the sharedfilelist have a corresponding hash in out list
// those how don'T are added to the hashinglist
CList<CAICHHash> liUsedHashs;
CSingleLock sharelock(&theApp.sharedfiles->m_mutWriteList);
sharelock.Lock();
for (uint32 i = 0; i < theApp.sharedfiles->GetCount(); i++){
CKnownFile* pCurFile = theApp.sharedfiles->GetFileByIndex(i);
if (pCurFile != NULL && !pCurFile->IsPartFile() ){
if (theApp.emuledlg==NULL || !theApp.emuledlg->IsRunning()) // in case of shutdown while still hashing
return 0;
if (pCurFile->GetAICHHashset()->GetStatus() == AICH_HASHSETCOMPLETE){
bool bFound = false;
for (POSITION pos = liKnown2Hashs.GetHeadPosition();pos != 0;)
{
CAICHHash current_hash = liKnown2Hashs.GetNext(pos);
if (current_hash == pCurFile->GetAICHHashset()->GetMasterHash()){
bFound = true;
liUsedHashs.AddTail(current_hash);
//theApp.QueueDebugLogLine(false, _T("%s - %s"), current_hash.GetString(), pCurFile->GetFileName());
#ifdef _DEBUG
// in debugmode we load and verify all hashsets
ASSERT( pCurFile->GetAICHHashset()->LoadHashSet() );
// pCurFile->GetAICHHashset()->DbgTest();
pCurFile->GetAICHHashset()->FreeHashSet();
#endif
break;
}
}
if (bFound) // hashset is available, everything fine with this file
continue;
}
pCurFile->GetAICHHashset()->SetStatus(AICH_ERROR);
m_liToHash.AddTail(pCurFile);
}
}
sharelock.Unlock();
//.........这里部分代码省略.........
示例6: ProcessPacket
bool CClientUDPSocket::ProcessPacket(const BYTE* packet, uint16 size, uint8 opcode, uint32 ip, uint16 port)
{
switch(opcode)
{
case OP_REASKCALLBACKUDP:
{
if (thePrefs.GetDebugClientUDPLevel() > 0)
DebugRecv("OP_ReaskCallbackUDP", NULL, NULL, ip);
theStats.AddDownDataOverheadOther(size);
CUpDownClient* buddy = theApp.clientlist->GetBuddy();
if( buddy )
{
if( size < 17 || buddy->socket == NULL )
break;
if (!md4cmp(packet, buddy->GetBuddyID()))
{
PokeUInt32(const_cast<BYTE*>(packet)+10, ip);
PokeUInt16(const_cast<BYTE*>(packet)+14, port);
Packet* response = new Packet(OP_EMULEPROT);
response->opcode = OP_REASKCALLBACKTCP;
response->pBuffer = new char[size];
memcpy(response->pBuffer, packet+10, size-10);
response->size = size-10;
if (thePrefs.GetDebugClientTCPLevel() > 0)
DebugSend("OP__ReaskCallbackTCP", buddy);
theStats.AddUpDataOverheadFileRequest(response->size);
buddy->socket->SendPacket(response);
}
}
break;
}
case OP_REASKFILEPING:
{
theStats.AddDownDataOverheadFileRequest(size);
CSafeMemFile data_in(packet, size);
uchar reqfilehash[16];
data_in.ReadHash16(reqfilehash);
CKnownFile* reqfile = theApp.sharedfiles->GetFileByID(reqfilehash);
if (!reqfile)
{
if (thePrefs.GetDebugClientUDPLevel() > 0) {
DebugRecv("OP_ReaskFilePing", NULL, reqfilehash, ip);
DebugSend("OP__FileNotFound", NULL);
}
Packet* response = new Packet(OP_FILENOTFOUND,0,OP_EMULEPROT);
theStats.AddUpDataOverheadFileRequest(response->size);
SendPacket(response, ip, port);
break;
}
CUpDownClient* sender = theApp.uploadqueue->GetWaitingClientByIP_UDP(ip, port);
if (sender)
{
if (thePrefs.GetDebugClientUDPLevel() > 0)
DebugRecv("OP_ReaskFilePing", sender, reqfilehash);
//Make sure we are still thinking about the same file
if (md4cmp(reqfilehash, sender->GetUploadFileID()) == 0)
{
sender->AddAskedCount();
sender->SetLastUpRequest();
//I messed up when I first added extended info to UDP
//I should have originally used the entire ProcessExtenedInfo the first time.
//So now I am forced to check UDPVersion to see if we are sending all the extended info.
//For now on, we should not have to change anything here if we change
//anything to the extended info data as this will be taken care of in ProcessExtendedInfo()
//Update extended info.
if (sender->GetUDPVersion() > 3)
{
sender->ProcessExtendedInfo(&data_in, reqfile);
}
//Update our complete source counts.
else if (sender->GetUDPVersion() > 2)
{
uint16 nCompleteCountLast= sender->GetUpCompleteSourcesCount();
uint16 nCompleteCountNew = data_in.ReadUInt16();
sender->SetUpCompleteSourcesCount(nCompleteCountNew);
if (nCompleteCountLast != nCompleteCountNew)
{
reqfile->UpdatePartsInfo();
}
}
CSafeMemFile data_out(128);
if(sender->GetUDPVersion() > 3)
{
if (reqfile->IsPartFile())
((CPartFile*)reqfile)->WritePartStatus(&data_out);
else
data_out.WriteUInt16(0);
}
data_out.WriteUInt16(theApp.uploadqueue->GetWaitingPosition(sender));
if (thePrefs.GetDebugClientUDPLevel() > 0)
DebugSend("OP__ReaskAck", sender);
Packet* response = new Packet(&data_out, OP_EMULEPROT);
response->opcode = OP_REASKACK;
theStats.AddUpDataOverheadFileRequest(response->size);
theApp.clientudp->SendPacket(response, ip, port);
}
else
{
//.........这里部分代码省略.........
示例7: OnCommand
BOOL CSharedDirsTreeCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
CTypedPtrList<CPtrList, CKnownFile*> selectedList;
int iSelectedItems = m_pSharedFilesCtrl->GetItemCount();
for (int i = 0; i < iSelectedItems; i++)
{
selectedList.AddTail((CKnownFile*)m_pSharedFilesCtrl->GetItemData(i));
}
CDirectoryItem* pSelectedDir = GetSelectedFilter();
// folder based
if (pSelectedDir != NULL){
switch (wParam){
case MP_OPENFOLDER:
if (pSelectedDir && pSelectedDir->m_eItemType == SDI_NO){
ShellExecute(NULL, _T("open"), pSelectedDir->m_strFullPath, NULL, NULL, SW_SHOW);
}
break;
case MP_SHAREDIR:
EditSharedDirectories(pSelectedDir, true, false);
break;
case MP_SHAREDIRSUB:
EditSharedDirectories(pSelectedDir, true, true);
break;
case MP_UNSHAREDIR:
EditSharedDirectories(pSelectedDir, false, false);
break;
case MP_UNSHAREDIRSUB:
EditSharedDirectories(pSelectedDir, false, true);
break;
}
}
// file based
if (selectedList.GetCount() > 0 && pSelectedDir != NULL)
{
CKnownFile* file = NULL;
if (selectedList.GetCount() == 1)
file = selectedList.GetHead();
switch (wParam){
case MP_GETED2KLINK:{
CString str;
POSITION pos = selectedList.GetHeadPosition();
while (pos != NULL)
{
file = selectedList.GetNext(pos);
if (!str.IsEmpty())
str += _T("\r\n");
str += CreateED2kLink(file);
}
theApp.CopyTextToClipboard(str);
break;
}
// file operations
case MP_REMOVE:
case MPG_DELETE:{
if (IDNO == AfxMessageBox(GetResString(IDS_CONFIRM_FILEDELETE),MB_ICONWARNING | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_YESNO))
return TRUE;
m_pSharedFilesCtrl->SetRedraw(FALSE);
bool bRemovedItems = false;
while (!selectedList.IsEmpty())
{
CKnownFile* myfile = selectedList.RemoveHead();
if (!myfile || myfile->IsPartFile())
continue;
BOOL delsucc = FALSE;
if (!PathFileExists(myfile->GetFilePath()))
delsucc = TRUE;
else{
// Delete
if (!thePrefs.GetRemoveToBin()){
delsucc = DeleteFile(myfile->GetFilePath());
}
else{
// delete to recycle bin :(
TCHAR todel[MAX_PATH+1];
memset(todel, 0, sizeof todel);
_tcsncpy(todel, myfile->GetFilePath(), ARRSIZE(todel)-2);
SHFILEOPSTRUCT fp = {0};
fp.wFunc = FO_DELETE;
fp.hwnd = theApp.emuledlg->m_hWnd;
fp.pFrom = todel;
fp.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_SILENT;// | FOF_NOERRORUI
delsucc = (SHFileOperation(&fp) == 0);
}
}
if (delsucc){
theApp.sharedfiles->RemoveFile(myfile);
bRemovedItems = true;
if (myfile->IsKindOf(RUNTIME_CLASS(CPartFile)))
theApp.emuledlg->transferwnd->downloadlistctrl.ClearCompleted(static_cast<CPartFile*>(myfile));
}
else{
CString strError;
strError.Format( GetResString(IDS_ERR_DELFILE) + _T("\r\n\r\n%s"), myfile->GetFilePath(), GetErrorMessage(GetLastError()));
AfxMessageBox(strError);
//.........这里部分代码省略.........
示例8: Run
int CAICHSyncThread::Run()
{
//MORPH START SLUGFILLER: SafeHash
CReadWriteLock lock(&theApp.m_threadlock);
if (!lock.ReadLock(0))
return 0;
// MORPH END SLUGFILLER: SafeHash
if ( !theApp.emuledlg->IsRunning() )
return 0;
// we need to keep a lock on this file while the thread is running
CSingleLock lockKnown2Met(&CAICHRecoveryHashSet::m_mutKnown2File);
lockKnown2Met.Lock();
CSafeFile file;
bool bJustCreated = ConvertToKnown2ToKnown264(&file);
// we collect all masterhashs which we find in the known2.met and store them in a list
CList<CAICHHash> liKnown2Hashs;
CString fullpath = thePrefs.GetMuleDirectory(EMULE_CONFIGDIR);
fullpath.Append(KNOWN2_MET_FILENAME);
CFileException fexp;
uint32 nLastVerifiedPos = 0;
if (!bJustCreated && !file.Open(fullpath,CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate|CFile::osSequentialScan|CFile::typeBinary|CFile::shareDenyNone, &fexp)){
if (fexp.m_cause != CFileException::fileNotFound){
CString strError(_T("Failed to load ") KNOWN2_MET_FILENAME _T(" file"));
TCHAR szError[MAX_CFEXP_ERRORMSG];
if (fexp.GetErrorMessage(szError, ARRSIZE(szError))){
strError += _T(" - ");
strError += szError;
}
LogError(LOG_STATUSBAR, _T("%s"), strError);
}
return false;
}
try {
if (file.GetLength() >= 1){
uint8 header = file.ReadUInt8();
if (header != KNOWN2_MET_VERSION){
AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName());
}
//setvbuf(file.m_pStream, NULL, _IOFBF, 16384);
uint32 nExistingSize = (UINT)file.GetLength();
uint32 nHashCount;
while (file.GetPosition() < nExistingSize){
liKnown2Hashs.AddTail(CAICHHash(&file));
nHashCount = file.ReadUInt32();
if (file.GetPosition() + nHashCount*CAICHHash::GetHashSize() > nExistingSize){
AfxThrowFileException(CFileException::endOfFile, 0, file.GetFileName());
}
// skip the rest of this hashset
file.Seek(nHashCount*CAICHHash::GetHashSize(), CFile::current);
nLastVerifiedPos = (UINT)file.GetPosition();
}
}
else
file.WriteUInt8(KNOWN2_MET_VERSION);
}
catch(CFileException* error){
if (error->m_cause == CFileException::endOfFile){
LogError(LOG_STATUSBAR,GetResString(IDS_ERR_MET_BAD), KNOWN2_MET_FILENAME);
// truncate the file to the size to the last verified valid pos
try{
file.SetLength(nLastVerifiedPos);
if (file.GetLength() == 0){
file.SeekToBegin();
file.WriteUInt8(KNOWN2_MET_VERSION);
}
}
catch(CFileException* error2){
error2->Delete();
}
}
else{
TCHAR buffer[MAX_CFEXP_ERRORMSG];
error->GetErrorMessage(buffer, ARRSIZE(buffer));
LogError(LOG_STATUSBAR,GetResString(IDS_ERR_SERVERMET_UNKNOWN),buffer);
}
error->Delete();
return false;
}
// now we check that all files which are in the sharedfilelist have a corresponding hash in out list
// those who don'T are added to the hashinglist
CList<CAICHHash> liUsedHashs;
CSingleLock sharelock(&theApp.sharedfiles->m_mutWriteList);
sharelock.Lock();
bool bDbgMsgCreatingPartHashs = true;
for (int i = 0; i < theApp.sharedfiles->GetCount(); i++){
CKnownFile* pCurFile = theApp.sharedfiles->GetFileByIndex(i);
if (pCurFile != NULL && !pCurFile->IsPartFile() )
{
if (theApp.emuledlg==NULL || !theApp.emuledlg->IsRunning()) // in case of shutdown while still hashing
return 0;
if (pCurFile->GetFileIdentifier().HasAICHHash()){
bool bFound = false;
for (POSITION pos = liKnown2Hashs.GetHeadPosition();pos != 0;)
{
//.........这里部分代码省略.........