void Http::download ( const std::string &url, const std::string &file, unsigned int timeoutMilliSeconds, Unknown *caller ) { // Open file. std::ofstream stream ( file.c_str(), std::ofstream::binary | std::ofstream::out ); if ( false == stream.is_open() ) { throw std::runtime_error ( "Error 2742979881: Failed to open file '" + file + "' for writing" ); } // This will remove the file is there's an exception. Usul::Scope::RemoveFile removeFile ( file ); Http http ( url, &stream, caller ); http.download( timeoutMilliSeconds ); // Keep the file. removeFile.remove ( false ); }