UTF-16 path for CreateFile-free portability: the loader uses `std::fopen`, which on Windows takes an ANSI path. The pack lives beside the executable in practice, but a pack under a user directory with a non-ASCII name would silently fail to open, so the caller gets the errno rather than a null pointer.
| 81 | /// path. The pack lives beside the executable in practice, but a pack under a user directory with a |
| 82 | /// non-ASCII name would silently fail to open, so the caller gets the errno rather than a null pointer. |
| 83 | bool read_at(std::FILE* f, uint64_t off, void* dst, size_t n, std::string& err, const char* what) { |
| 84 | #if defined(_WIN32) |
| 85 | if (_fseeki64(f, (long long) off, SEEK_SET) != 0) { err = std::string(what) + ": seek failed"; return false; } |
| 86 | #else |
| 87 | if (fseeko(f, (off_t) off, SEEK_SET) != 0) { err = std::string(what) + ": seek failed"; return false; } |
| 88 | #endif |
| 89 | if (std::fread(dst, 1, n, f) != n) { err = std::string(what) + ": short read"; return false; } |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | } // namespace |
| 94 |
no test coverage detected