MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / readFile

Method readFile

src/core/vfs/WinResFS.cpp:76–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76std::shared_ptr<IBlob> WinResFileSystem::readFile(const fs::path& name)
77{
78 std::string nameString = name.lexically_normal().generic_string();
79 donut::string_utils::ltrim(nameString, '/');
80
81 HRSRC hResource = FindResourceA((HMODULE)m_hModule, nameString.c_str(), m_Type.c_str());
82
83 if (hResource == nullptr)
84 return nullptr;
85
86 DWORD size = SizeofResource((HMODULE)m_hModule, hResource);
87 if (size == 0)
88 {
89 // empty resource (can that really happen?)
90 return std::make_shared<NonOwningBlob>(nullptr, 0);
91 }
92
93 HGLOBAL hGlobal = LoadResource((HMODULE)m_hModule, hResource);
94
95 if (hGlobal == nullptr)
96 return nullptr;
97
98 void* pData = LockResource(hGlobal);
99 return std::make_shared<NonOwningBlob>(pData, size);
100}
101
102bool WinResFileSystem::writeFile(const fs::path&, const void*, size_t)
103{

Callers

nothing calls this directly

Calls 1

ltrimFunction · 0.85

Tested by

no test coverage detected