| 245 | /* Archives */ |
| 246 | |
| 247 | void 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 | |
| 275 | IC void CLocatorAPI::archive::index(CLocatorAPI& loc, const char* fs_entry_point) |
| 276 | { |
no test coverage detected