当前位置: 技术问答>linux和unix
迅雷不能完全下载文件
来源: 互联网 发布时间:2017-03-17
本文导语: 公司的设备内置小型嵌入式服务器,里面用的是cgic编写的脚本,其中有一个叫downfile,专门负责下载文件,但是当下载文件時,选择本地保存,文件下载无误;但是当打开迅雷,选择下载被迅雷捕捉后下载,这时有的...
公司的设备内置小型嵌入式服务器,里面用的是cgic编写的脚本,其中有一个叫downfile,专门负责下载文件,但是当下载文件時,选择本地保存,文件下载无误;但是当打开迅雷,选择下载被迅雷捕捉后下载,这时有的文件可以下载99.9%然后就停止了说是没有资源,有的则是一直都是0%,停滞不前。。。。。。。。。我先在需要解决这根问题但是不知道从何入手,一片茫然。。。。。。还望哪位大神赐教,下面是downfile 源码:
int cgiMain()
{
int nRec = 0;
char pUserName[BUFLENGTH] = {NULL};
char pVideoName[BUFLENGTH] = {NULL};
char pTemp[BUFLENGTH] = {NULL};
char pPathName[BUFLENGTH] = {NULL};
JYCGISession *pCGISession = new JYCGISession();
nRec = pCGISession->CheckSession(pUserName);
JYCTPLFile *pCTPLFile = new JYCTPLFile();
if(nRec > 0 && NULL != pUserName)
{
if( strlen(cgiQueryString) > 0)
{
#ifdef _ARM_
strcpy(pPathName,"/video/HardDisk/recordfiles/VideoRecord/");
//取得html页面中file元素的值,应该是文件在客户机上的路径名
cgiFormString("FileName",pTemp,BUFLENGTH);
strcat(pPathName,pTemp);
strcpy( pVideoName, rindex(pTemp ,'/') + 1);
#elif _MIPS_
strcpy(pPathName,"/video/HardDisk/recordfiles/");
//取得html页面中file元素的值,应该是文件在客户机上的路径名
cgiFormString("FileName",pTemp,BUFLENGTH);
strcat(pPathName,pTemp);
strcpy( pVideoName, rindex(pTemp ,'/') + 1);
#else
strcpy(pTemp , cgiQueryString);
if(strstr(pTemp , "="))
{
strcpy(pPathName,"/video/HardDisk/recordfiles/");
strcpy( pVideoName, rindex(pTemp ,'/') + 1);
strcat(pPathName,pVideoName);//拼写完整文件路径
}
#endif
if( NULL != pTemp )
{
FILE *fp;
struct stat64 sb;
stat64(pPathName,&sb);
//下载所需的http头信息
printf("Content-Type:application/binary-streamn");
printf("Content-Length:%llun",sb.st_size);
printf("Content-Disposition:attachment;filename=%snn",pVideoName);
char pathbuff1[256] = {0};
char pathbuff2[256] = {0};
char namebuff[256] = {0};
char *p = strstr(pVideoName,".");
strncpy(namebuff, pVideoName, 1);
sprintf(pathbuff1,"/tmp/%s1.log",namebuff);
sprintf(pathbuff2,"/tmp/%s2.log",namebuff);
char systemcmd1[100] = {0};
char systemcmd2[100] = {0};
//判断系统中有几个downloadfile.cgi正在运行,并写入临时文件
sprintf(systemcmd1,"ps | grep downloadfile.cgi>%s",pathbuff1);
sprintf(systemcmd2,"wc -l %s>%s",pathbuff1,pathbuff2);
system(systemcmd1);
system(systemcmd2);
//从临时文件中读出本进程运行的个数
int fd;
int num = 0;
fd = open(pathbuff2, O_RDWR);
char r_buff[10] = {0};
memset(r_buff, 0, 10);
lseek(fd, 0, SEEK_SET);
sync();
flock(fd, LOCK_SH|LOCK_NB);
read(fd, r_buff, 10);
flock(fd, LOCK_UN);
//num = atoi(r_buff);
int flag = 0;
for(int i=0; i='0'&&r_buff[i]Open("./tpl/change_error.html");
if(nRec > 0)
{
pCTPLFile->SetData("{$ERROR_INFO$}" , "非法操作,该用户权限不够");
pCTPLFile->WriteToStream(cgiOut);
pCTPLFile->Close();
}
else
{
exit(0);
}
}
if(pCTPLFile)
{
delete pCTPLFile;
}
if(pCGISession)
{
delete pCGISession;
}
return 0;
}
int cgiMain()
{
int nRec = 0;
char pUserName[BUFLENGTH] = {NULL};
char pVideoName[BUFLENGTH] = {NULL};
char pTemp[BUFLENGTH] = {NULL};
char pPathName[BUFLENGTH] = {NULL};
JYCGISession *pCGISession = new JYCGISession();
nRec = pCGISession->CheckSession(pUserName);
JYCTPLFile *pCTPLFile = new JYCTPLFile();
if(nRec > 0 && NULL != pUserName)
{
if( strlen(cgiQueryString) > 0)
{
#ifdef _ARM_
strcpy(pPathName,"/video/HardDisk/recordfiles/VideoRecord/");
//取得html页面中file元素的值,应该是文件在客户机上的路径名
cgiFormString("FileName",pTemp,BUFLENGTH);
strcat(pPathName,pTemp);
strcpy( pVideoName, rindex(pTemp ,'/') + 1);
#elif _MIPS_
strcpy(pPathName,"/video/HardDisk/recordfiles/");
//取得html页面中file元素的值,应该是文件在客户机上的路径名
cgiFormString("FileName",pTemp,BUFLENGTH);
strcat(pPathName,pTemp);
strcpy( pVideoName, rindex(pTemp ,'/') + 1);
#else
strcpy(pTemp , cgiQueryString);
if(strstr(pTemp , "="))
{
strcpy(pPathName,"/video/HardDisk/recordfiles/");
strcpy( pVideoName, rindex(pTemp ,'/') + 1);
strcat(pPathName,pVideoName);//拼写完整文件路径
}
#endif
if( NULL != pTemp )
{
FILE *fp;
struct stat64 sb;
stat64(pPathName,&sb);
//下载所需的http头信息
printf("Content-Type:application/binary-streamn");
printf("Content-Length:%llun",sb.st_size);
printf("Content-Disposition:attachment;filename=%snn",pVideoName);
char pathbuff1[256] = {0};
char pathbuff2[256] = {0};
char namebuff[256] = {0};
char *p = strstr(pVideoName,".");
strncpy(namebuff, pVideoName, 1);
sprintf(pathbuff1,"/tmp/%s1.log",namebuff);
sprintf(pathbuff2,"/tmp/%s2.log",namebuff);
char systemcmd1[100] = {0};
char systemcmd2[100] = {0};
//判断系统中有几个downloadfile.cgi正在运行,并写入临时文件
sprintf(systemcmd1,"ps | grep downloadfile.cgi>%s",pathbuff1);
sprintf(systemcmd2,"wc -l %s>%s",pathbuff1,pathbuff2);
system(systemcmd1);
system(systemcmd2);
//从临时文件中读出本进程运行的个数
int fd;
int num = 0;
fd = open(pathbuff2, O_RDWR);
char r_buff[10] = {0};
memset(r_buff, 0, 10);
lseek(fd, 0, SEEK_SET);
sync();
flock(fd, LOCK_SH|LOCK_NB);
read(fd, r_buff, 10);
flock(fd, LOCK_UN);
//num = atoi(r_buff);
int flag = 0;
for(int i=0; i='0'&&r_buff[i]Open("./tpl/change_error.html");
if(nRec > 0)
{
pCTPLFile->SetData("{$ERROR_INFO$}" , "非法操作,该用户权限不够");
pCTPLFile->WriteToStream(cgiOut);
pCTPLFile->Close();
}
else
{
exit(0);
}
}
if(pCTPLFile)
{
delete pCTPLFile;
}
if(pCGISession)
{
delete pCGISession;
}
return 0;
}
|
wine的迅雷 应该以win98模式运行. 否则可能会出现到99%时不动的情形.
不知道你的是什么情况.
不知道你的是什么情况.
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。