struct POS
{
LONG start;
LONG end;
POS()
{
start=-1;
end=-1;
}
};
struct INFO
{
char url[100];
char localFile[50];
BOOL ifFinish;
BOOL MulThread;
long fileLen;
POS pos[4];
long lenFinish;
CTime lastModify;
INFO()
{
url[0]='\0';
localFile[0]='\0';
ifFinish=TRUE;
MulThread=TRUE;
fileLen=-1;
lenFinish=0;
}
};
{
LONG start;
LONG end;
POS()
{
start=-1;
end=-1;
}
};
struct INFO
{
char url[100];
char localFile[50];
BOOL ifFinish;
BOOL MulThread;
long fileLen;
POS pos[4];
long lenFinish;
CTime lastModify;
INFO()
{
url[0]='\0';
localFile[0]='\0';
ifFinish=TRUE;
MulThread=TRUE;
fileLen=-1;
lenFinish=0;
}
};
而且读数据的时候可以按上边的链表顺序来读,各种不同内容的结点从一个基类派生出来。
{
LONG start;
LONG end;
POS()
{
start=-1;
end=-1;
}
};
struct INFO
{
char url[100];
char localFile[50];
BOOL ifFinish;
BOOL MulThread;
long fileLen;
POS pos[4];
long lenFinish;
CTime lastModify;
INFO()
{
url[0]='\0';
localFile[0]='\0';
ifFinish=TRUE;
MulThread=TRUE;
fileLen=-1;
lenFinish=0;
}
};
void CHttpBotDlg::ReadInfo(BOOL isFinish)
{
m_tList.DeleteAllItems();
// ifFinishList=IsFinish;
CFile file;
if(!file.Open("d:\\HttpBot.txt", CFile::modeRead))
{
file.Open("d:\\HttpBot.txt",CFile::modeCreate);
file.Close();
return;
}
else
{
INFO *info = new INFO();
file.SeekToBegin();
int index;
while(file.Read(info,sizeof(INFO)) == sizeof(INFO))
{
if(info->ifFinish != isFinish)
continue;
ITEMINFO *item = new ITEMINFO();
if(isFinish == FALSE)
{
CFile f;
LONG size=0;
for(int i=0; i<4; i++)
{
CString name;
name.Format(".bot%d",i);
name = info->localFile+name;
if(f.Open(name, CFile::modeRead))
{
size+=f.GetLength();
f.Close();
}
}
item->downloadSize = size;
}
item->fileSize = info->fileLen;
// int ti = info->fileLen / 100;
item->downloadSize = info->lenFinish;
item->per = (item->downloadSize / item->fileSize) * 100;
CString temp = info->localFile;
int j = temp.ReverseFind('\\');
item->fileName = temp.Mid(j + 1);
item->savePath = temp.Left(j+1);
item->remoteUrl = info->url;
item->per = (info->lenFinish * 100) / info->fileLen;
if(isFinish)
item->state = TA_FINISH;
else
item->state = TA_STOP;
index = m_tList.InsertItem(item);
delete item;
item = NULL;
}
file.Close();
}
}