MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / InitializeFileStorage

Method InitializeFileStorage

Sources/Shared/IO/WebRequest.cpp:769–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767 }
768
769 WebRequest::Result WebResponseImpl::InitializeFileStorage()
770 {
771 if (_request.GetStorage() == WebRequest::Storage::File) {
772 String tempDir = _request.GetSessionImpl().GetTempDirectory();
773 std::uint64_t hash = Environment::QueryUnbiasedInterruptTime() * 11400714819323198485ULL;
774 for (std::int32_t i = 0; i < 10; i++) {
775 char fileName[64];
776 std::size_t length = formatInto(fileName, "Dx-{:.8x}-{:.8x}", std::uint32_t((hash >> 32) & 0xffffffff), std::uint32_t(hash & 0xffffffff));
777 _file = std::make_unique<FileStream>(FileSystem::CombinePath(tempDir, { fileName, length }), FileAccess::Write);
778 if (_file->IsValid()) {
779 break;
780 }
781
782 _file = nullptr;
783 hash ^= hash >> 33;
784 hash *= 0xFF51AFD7ED558CCDULL;
785 }
786
787 if (_file == nullptr || _file->IsValid()) {
788 return WebRequest::Result::Error("Failed to create temporary file");
789 }
790 }
791
792 return WebRequest::Result::Ok();
793 }
794
795 String WebResponseImpl::GetMimeType() const
796 {

Callers 2

CreateResponseMethod · 0.80
DoFinishPrepareMethod · 0.80

Calls 4

formatIntoFunction · 0.85
GetStorageMethod · 0.45
GetTempDirectoryMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected