MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / open

Method open

ogsr_engine/xrCore/LocatorAPI.cpp:247–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245/* Archives */
246
247void CLocatorAPI::archive::open()
248{
249 // Open the file
250 if (hSrcFile && hSrcMap)
251 return;
252
253 hSrcFile = CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
254 R_ASSERT(hSrcFile != INVALID_HANDLE_VALUE);
255
256 LARGE_INTEGER sz;
257 GetFileSizeEx(hSrcFile, &sz);
258 size = sz.QuadPart;
259 R_ASSERT(size > 0);
260
261 u32 dwPtr = SetFilePointer(hSrcFile, 0, nullptr, FILE_BEGIN);
262 R_ASSERT(dwPtr != INVALID_SET_FILE_POINTER, path.c_str(), Debug.error2string(GetLastError()));
263
264 u32 magic = u32(-1);
265 DWORD read_byte;
266 bool res = ReadFile(hSrcFile, &magic, 4, &read_byte, nullptr);
267 R_ASSERT(res && read_byte == sizeof(u32), path.c_str(), Debug.error2string(GetLastError()));
268
269 if (magic == SQFS_MAGIC)
270 open_sqfs();
271 else
272 open_db();
273}
274
275IC void CLocatorAPI::archive::index(CLocatorAPI& loc, const char* fs_entry_point)
276{

Callers 3

LoadArchiveMethod · 0.45
ProcessArchiveMethod · 0.45
CreateLogFunction · 0.45

Calls 4

ReadFileFunction · 0.85
error2stringMethod · 0.80
u32Enum · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected