MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / MapBinaryFileForRead

Method MapBinaryFileForRead

common/FileSystem.cpp:1295–1313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1293#endif
1294
1295std::span<const u8> FileSystem::MapBinaryFileForRead(const char* path)
1296{
1297#ifdef _WIN32
1298 const std::wstring wpath = GetWin32Path(path);
1299 HANDLE handle = CreateFileW(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
1300 if (handle == INVALID_HANDLE_VALUE)
1301 return {};
1302 std::span<const u8> result = ::MapBinaryFileForRead(handle);
1303 CloseHandle(handle);
1304 return result;
1305#else
1306 int fd = open(path, O_RDONLY);
1307 if (fd <= 0)
1308 return {};
1309 std::span<const u8> result = ::MapBinaryFileForRead(fd);
1310 close(fd);
1311 return result;
1312#endif
1313}
1314
1315std::span<const u8> FileSystem::MapBinaryFileForRead(std::FILE* fp)
1316{

Callers

nothing calls this directly

Calls 3

MapBinaryFileForReadFunction · 0.85
CloseHandleFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected