Closed GloriousEggroll closed 6 years ago
Do you think you could split out only the firstrun changes? Preferrably without changing indentation on every single line as well.
I'm cleaning this up on a new branch, trying to implement your writeFile method with:
FILE* fp;
fopen_s(&fp, "directx_Jun2010_redist.exe", "wb");
if (!fp)
{
std::wcout << "Failed to create file on disk." << std::endl;
}
CURL *curl = curl_easy_init();
FileWrapper *wrap = new FileWrapper { fp };
curl_easy_setopt(curl, CURLOPT_URL, ("https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe"));
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Warframe_on_Proton)");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, wrap);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeFile);
CURLcode res;
res = curl_easy_perform(curl);
delete wrap;
but it's giving me this error:
object has an uninitialized const or reference member
for FileWrapper *wrap = new FileWrapper { fp };
because it's expecting a hash with it:
struct FileWrapper
{
FILE* stream;
const Hashlist::RemoteHash& file;
};
If you look at https://github.com/ananace/wf_proton_launcher/blob/master/WF_Proton_Launcher/Main.cpp#L594 you'll see an example of how it's done for the LZMA-compressed files.
Both the CompressedFileWrapper and the FileWrapper structs expect to begiven a FILE* as the first value, that's the reason for the initializer list.
The hash itself can just be in-place allocated.
Though I later realized that since that whole code happens in the same scope, it could be simplified by just using a regular stack object instead of allocating it on the heap.
{
// ...
FILE* fp;
CURL *curl = curl_easy_init();
// ...
FileWrapper wrap{ fp, {} };
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &wrap);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeFile);
CURLcode res;
res = curl_easy_perform(curl);
// ...
}
TODO: Still need the wininet portion for proton, but I don't think it should be included here, as it's something valve needs to/may patch in. I'll write a bash script for the wininet patch. I feel that's a better solution to be run seperately until it's resolved in proton