| | |
| | | request.channel, |
| | | mktime(&start), |
| | | i); |
| | | // printf("%s\n", destfile); |
| | | if(downloadByTime_wrapper(userid, request.channel, &start, &end, destfile) != -1) { |
| | | std::cout << "destfile:" << destfile << std::endl; |
| | | char *destfiledup = strdup(destfile); |
| | | if(downloadByTime_wrapper(userid, request.channel, &start, &end, destfiledup) != -1) { |
| | | if(files != NULL) { |
| | | // std::cout << "push destfile:" << destfile << std::endl; |
| | | files->push_back(destfile); |
| | | } |
| | | } |
| | | free(destfiledup); |
| | | |
| | | start = end; |
| | | i++; |
| | |
| | | /** |
| | | * @return success: 0, failture : -1 |
| | | */ |
| | | int HCNetdisk::downloadByTime_wrapper(long userid, int channel, struct tm *start, struct tm *end, char *destfile) { |
| | | int HCNetdisk::downloadByTime_wrapper(const long userid, const int channel, const struct tm *start, const struct tm *end, const char *destfile) { |
| | | NET_DVR_FILECOND_V40 struFileCond = {0}; |
| | | struFileCond.dwFileType = 0xFF; |
| | | |
| | |
| | | char strFileName[256] = {0}; |
| | | if (destfile != NULL) { |
| | | sprintf(strFileName, "%s", destfile); |
| | | char *dir = dirname(strdup(destfile)); |
| | | //char *dir = dirname(strdup(destfile)); |
| | | char *dir = dirname(const_cast<char *>(destfile)); |
| | | printf("dir === %s\n", dir); |
| | | if ((mkdir(dir, DIR_MODE) == -1) && (errno != EEXIST)) { |
| | | err_msg(errno, "hc_downloadByTime mkdir error "); |
| | |
| | | |
| | | |
| | | |
| | | int HCNetdisk::saveRecordFile(int userId, char * srcfile, char * destfile) |
| | | int HCNetdisk::saveRecordFile( int userId, char * srcfile, char * destfile) |
| | | { |
| | | printf("destfile=%s\n", destfile); |
| | | int bRes = 1; |
| | | int hPlayback = 0; |
| | | //按文件名下载录像 |
| | |
| | | return bRes; |
| | | } |
| | | int nPos = 0; |
| | | //下载进度 |
| | | for (nPos = 0; nPos < 100 && nPos >= 0; nPos = NET_DVR_GetDownloadPos(hPlayback)) |
| | | { |
| | | printf("Be downloading...%d %%\n", nPos); |
| | | sleep(1); |
| | | //下载进度 |
| | | //millisecond |
| | | } |
| | | printf("have got %d\n", nPos); |
| | | // printf("have got %d\n", nPos); |
| | | //停止下载 |
| | | if (!NET_DVR_StopGetFile(hPlayback)) |
| | | { |
| | |
| | | bRes = -1; |
| | | return bRes; |
| | | } |
| | | printf("%s\n", srcfile); |
| | | // printf("%s\n", srcfile); |
| | | if (nPos < 0 || nPos > 100) |
| | | { |
| | | printf("download err [%d]\n", NET_DVR_GetLastError()); |