Well after a morning yesterday of getting a fresh Repo, changed to VisualStudio 22 from 17, & updating to a supported version of CMake, I managed to do a VS build & get a running un-modified playground in the afternoon.
I also finished my first cut of the code changes this morning in the areas you indicated. I get no visual errors in the VS tab for the file, but get build complaints from arcana:
1>UrlRequest.cpp
1>C:\BabylonNative\Dependencies\arcana.cpp\Source\Shared\arcana\threading\internal\callable_traits.h(40,1): error C2064: term does not evaluate to a function taking 0 arguments
1>C:\BabylonNative\Dependencies\arcana.cpp\Source\Shared\arcana\threading\internal\callable_traits.h(40,1): message : class does not define an 'operator()' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments
1>C:\BabylonNative\Dependencies\arcana.cpp\Source\Shared\arcana\threading\internal\callable_traits.h(93): message : see reference to class template instantiation 'arcana::internal::invoke_result<UrlLib::UrlRequest::Impl::SaveFileAsync::<lambda_6145541bc23ba1dd93ae32ac95755190>,std::integral_constant<bool,false>,void>' being compiled
1>C:\BabylonNative\Dependencies\arcana.cpp\Source\Shared\arcana/threading/task.h(97): message : see reference to class template instantiation 'arcana::internal::callable_traits<CallableT,void>' being compiled
1> with
1> [
1> CallableT=UrlLib::UrlRequest::Impl::SaveFileAsync::<lambda_6145541bc23ba1dd93ae32ac95755190>
1> ]
1>C:\BabylonNative\Dependencies\UrlLib\Source\Windows\UrlRequest.cpp(244): message : see reference to function template instantiation 'auto arcana::task<void,std::exception_ptr>::then<const arcana::`anonymous-namespace'::<lambda_86fcb5e973fcdacccc4842e1526a0ecf>,UrlLib::UrlRequest::Impl::SaveFileAsync::<lambda_6145541bc23ba1dd93ae32ac95755190>>(SchedulerT &,arcana::cancellation &,CallableT &&)' being compiled
1> with
1> [
1> SchedulerT=const arcana::`anonymous-namespace'::<lambda_86fcb5e973fcdacccc4842e1526a0ecf>,
1> CallableT=UrlLib::UrlRequest::Impl::SaveFileAsync::<lambda_6145541bc23ba1dd93ae32ac95755190>
1> ]
I have never used arcana before, so not sure where to go from here, so I am just going to list my changes from lowest call to highest for comment.
Made a SaveFileAsync
method very similar to the existing LoadFileAsync
, but smaller. I suspect I am having an issue that WriteTextAsync()
does not actually return text, so the assignment of m_responseString
should not be done. I do not know how to remove this:
arcana::task<void, std::exception_ptr> SaveFileAsync(Storage::StorageFile file)
{
return arcana::create_task<std::exception_ptr>(Storage::FileIO::WriteTextAsync(file, m_putContentsString))
.then(arcana::inline_scheduler, m_cancellationSource, [this](winrt::hstring text) {
m_responseString = winrt::to_string(text);
m_statusCode = UrlStatusCode::Ok;
});
}
This is called in my revised SendAsync
method with the added putContents
arg. The code is very similar to the Get, but without a section for doing it over the network.
arcana::task<void, std::exception_ptr> SendAsync(std::string putContents)
{
try
{
if (m_method == UrlMethod::Get)
{
... // same as before
}
else // Put part
{
m_putContentsString = winrt::to_hstring(putContents);
if (m_uri.SchemeName() == L"app")
{
return arcana::create_task<std::exception_ptr>(Storage::StorageFolder::GetFolderFromPathAsync(GetInstalledLocation()))
.then(arcana::inline_scheduler, m_cancellationSource, [this, m_uri{m_uri}](Storage::StorageFolder folder) {
return arcana::create_task<std::exception_ptr>(folder.GetFileAsync(GetLocalPath(m_uri)));
})
.then(arcana::inline_scheduler, m_cancellationSource, [this](Storage::StorageFile file) {
return SaveFileAsync(file);
});
}
else if (m_uri.SchemeName() == L"file")
{
return arcana::create_task<std::exception_ptr>(Storage::StorageFile::GetFileFromPathAsync(GetLocalPath(m_uri)))
.then(arcana::inline_scheduler, m_cancellationSource, [this](Storage::StorageFile file) {
return SaveFileAsync(file);
});
}
else
{
throw std::runtime_error{"Network PUT request not currently supported"};
}
}
}
catch (winrt::hresult_error)
{
// Catch WinRT exceptions, but retain the default status code of 0 to indicate a client side error.
return arcana::task_from_result<std::exception_ptr>();
}
}
There are also 2 little adds:
- add a check for a Put in
ConvertHttpMethod()
- list the member
winrt::hstring m_putContentsString{};
I’ll leave the changes to XMLHttpRequest.cpp
for later. Am I even close?