Downloads a given remote file and saves it as a local file
| 1038 | |
| 1039 | // Downloads a given remote file and saves it as a local file |
| 1040 | int CUpdateDlg::GetHTTPFile(char *remote, char *local) { |
| 1041 | uint32_t LastPrintbytes = time(NULL); |
| 1042 | InetGetFile *inetfile; |
| 1043 | WORD ver = MAKEWORD(1, 1); |
| 1044 | char URL[_MAX_PATH + 1]; |
| 1045 | |
| 1046 | // sprintf(URL,"%s://%s%s",SITE_TYPE,WEB_SITE,remote); |
| 1047 | strcpy(URL, remote); |
| 1048 | m_progress.SetRange(0, 100); |
| 1049 | m_progress.SetPos(0); |
| 1050 | |
| 1051 | CancelPressed = FALSE; |
| 1052 | downloading = TRUE; |
| 1053 | inetfile = new InetGetFile(URL, local); |
| 1054 | do { |
| 1055 | // Check if a download error has occurred |
| 1056 | if (inetfile->IsFileError()) { |
| 1057 | int new_error; |
| 1058 | int error = inetfile->GetErrorCode(); |
| 1059 | delete inetfile; |
| 1060 | downloading = FALSE; |
| 1061 | |
| 1062 | switch (error) { |
| 1063 | case INET_ERROR_BADPARMS: |
| 1064 | new_error = GETHTTPFILE_BADPARMS; |
| 1065 | break; |
| 1066 | case INET_ERROR_CANT_WRITE_FILE: |
| 1067 | new_error = GETHTTPFILE_CANT_WRITE_FILE; |
| 1068 | break; |
| 1069 | case INET_ERROR_CANT_PARSE_URL: |
| 1070 | new_error = GETHTTPFILE_CANT_PARSE_URL; |
| 1071 | break; |
| 1072 | case INET_ERROR_BAD_FILE_OR_DIR: |
| 1073 | new_error = GETHTTPFILE_BAD_FILE_OR_DIR; |
| 1074 | break; |
| 1075 | case INET_ERROR_HOST_NOT_FOUND: |
| 1076 | new_error = GETHTTPFILE_HOST_NOT_FOUND; |
| 1077 | break; |
| 1078 | case INET_ERROR_NO_MEMORY: |
| 1079 | new_error = GETHTTPFILE_NO_MEMORY; |
| 1080 | break; |
| 1081 | case INET_ERROR_UNKNOWN_ERROR: |
| 1082 | default: |
| 1083 | new_error = GETHTTPFILE_UNKNOWN_ERROR; |
| 1084 | break; |
| 1085 | } |
| 1086 | |
| 1087 | return new_error; |
| 1088 | } |
| 1089 | |
| 1090 | // check if the file has been received |
| 1091 | if (inetfile->IsFileReceived()) { |
| 1092 | delete inetfile; |
| 1093 | downloading = FALSE; |
| 1094 | // m_progress.SetPos(100); |
| 1095 | return GETHTTPFILE_OK; |
| 1096 | } |
| 1097 |
nothing calls this directly
no test coverage detected