* Handle the opening of the file before downloading. * @return false on any error. */
| 492 | * @return false on any error. |
| 493 | */ |
| 494 | bool ClientNetworkContentSocketHandler::BeforeDownload() |
| 495 | { |
| 496 | if (!this->cur_info->IsValid()) { |
| 497 | this->cur_info.reset(); |
| 498 | return false; |
| 499 | } |
| 500 | |
| 501 | if (this->cur_info->filesize != 0) { |
| 502 | /* The filesize is > 0, so we are going to download it */ |
| 503 | std::string filename = GetFullFilename(*this->cur_info, true); |
| 504 | if (filename.empty() || !(this->cur_file = FileHandle::Open(filename, "wb")).has_value()) { |
| 505 | /* Unless that fails of course... */ |
| 506 | CloseWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD); |
| 507 | ShowErrorMessage( |
| 508 | GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD), |
| 509 | GetEncodedString(STR_CONTENT_ERROR_COULD_NOT_DOWNLOAD_FILE_NOT_WRITABLE), |
| 510 | WL_ERROR); |
| 511 | return false; |
| 512 | } |
| 513 | } |
| 514 | return true; |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * Handle the closing and extracting of a file after |
no test coverage detected