Update of /cvsroot/cpptool/CppParser/src/pyrfta/samples/sources
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22607/samples/sources
Added Files:
MiniArchiveRecovery.cpp MiniPartFile.cpp
Log Message:
* added some sample sources that works with dumpast.py.
--- NEW FILE: MiniArchiveRecovery.cpp ---
// Excerpt from emule.sf.net sources
// At some point it may be worth displaying messages to alert the user if there were errors, or where to find the file.
void CArchiveRecovery::recover(CPartFile *partFile, bool preview)
{
if (partFile->m_bPreviewing || partFile->m_bRecoveringArchive)
return;
partFile->m_bRecoveringArchive = true;
theApp.emuledlg->AddLogLine(true, GetResString(IDS_ATTEMPTING_RECOVERY) );
// Get the current filled list for this file
CTypedPtrList<CPtrList, Gap_Struct*> *filled = new CTypedPtrList<CPtrList, Gap_Struct*>;
partFile->GetFilledList(filled);
// The rest of the work can be safely done in a new thread
ThreadParam *tp = new ThreadParam;
tp->partFile = partFile;
tp->filled = filled;
tp->preview = preview;
DWORD dwThreadId;
HANDLE hThread = CreateThread( NULL, // no security attributes
0, // use default stack size
run, // thread function
tp, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
// Check the return value for success.
if (hThread == NULL)
{
partFile->m_bRecoveringArchive = false;
theApp.emuledlg->AddLogLine(true, GetResString(IDS_RECOVERY_FAILED));
// Need to delete the memory here as won't be done in thread
DeleteMemory(tp);
}
}
--- NEW FILE: MiniPartFile.cpp ---
// Excerpt from emule.sf.net sources
CBarShader CPartFile::s_LoadBar(PROGRESS_HEIGHT); // Barry - was 5
CBarShader CPartFile::s_ChunkBar(16);
CPartFile::CPartFile()
{
Init();
}
CPartFile::CPartFile(CSearchFile* searchresult)
{
Init();
md4cpy(m_abyFileHash, searchresult->GetFileHash());
for (int i = 0; i < searchresult->taglist.GetCount();i++){
switch (searchresult->taglist[i]->tag->specialtag){
case FT_FILENAME:{
m_pszFileName = nstrdup(searchresult->taglist[i]->tag->stringvalue);
break;
}
case FT_FILESIZE:{
m_nFileSize = searchresult->taglist[i]->tag->intvalue;
break;
}
default:
CTag* newtag = new CTag(searchresult->taglist[i]->tag);
taglist.Add(newtag);
}
}
if(m_nFileSize < PARTSIZE )
hashsetneeded = false;
CreatePartFile();
}
void
CPartFile::InitializeFromLink(CED2KFileLink* fileLink)
{
Init();
try{
m_pszFileName = nstrdup( fileLink->GetName() );
m_nFileSize = fileLink->GetSize();
if(m_nFileSize < PARTSIZE )
hashsetneeded = false;
md4cpy(m_abyFileHash, fileLink->GetHashKey());
if (!theApp.downloadqueue->IsFileExisting(m_abyFileHash))
CreatePartFile();
else
status = PS_ERROR;
}
catch(CString error){
OUTPUT_DEBUG_TRACE();
char buffer[200];
sprintf(buffer, GetResString(IDS_ERR_INVALIDLINK), error.GetBuffer());
theApp.emuledlg->AddLogLine(true, GetResString(IDS_ERR_LINKERROR), buffer);
status = PS_ERROR;
}
}
CPartFile::~CPartFile(){
// Barry - Ensure all buffered data is written
FlushBuffer();
if (m_hpartfile.m_hFile != INVALID_HANDLE_VALUE){
// commit file and directory entry
m_hpartfile.Close();
// Update met file (with current directory entry)
SavePartFile();
}
if (fullname)
delete[] fullname;
if (partmetfilename)
delete[] partmetfilename;
m_SrcpartFrequency.RemoveAll();
for (POSITION pos = gaplist.GetHeadPosition();pos != 0;gaplist.GetNext(pos))
delete gaplist.GetAt(pos);
}
|