|
楼主 |
发表于 2009-10-9 17:17:16
|
显示全部楼层
m_mbFileBuffer.init(65536);
void TransmitFileToServer(char *pFileName)
{
if(pFileName == NULL)
return -1;
FILE *pFile = fopen(pFileName, "rt");
if(pFile == NULL)
return -1;
size_t fileSize = 0;
size_t readSize = 0;
size_t offset = 0;
fseek(pFile, 0, SEEK_END);
fileSize = ftell(pFile);
fseek(pFile, 0, SEEK_SET);
for(offset = 0; offset < fileSize; offset += readSize)
{
m_mbFileBuffer.rd_ptr(m_mbFileBuffer.base());
readSize = fread(m_mbFileBuffer.base(), 1, m_mbFileBuffer.size() - 1, pFile);
fseek(pFile, readSize, SEEK_CUR);
m_mbFileBuffer.wr_ptr(readSize);
if(m_ws.write(m_mbFileBuffer, readSize) == -1)
{
break;
}
}
fclose(pFile);
return 0;
} |
|