MCPcopy Create free account
hub / github.com/Niko1221/Strata / read_at

Function read_at

engine/src/core/weights.cpp:83–91  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
83bool 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

Callers 7

read_bf16_hostMethod · 0.70
loadMethod · 0.70
read_rawMethod · 0.50
read_sectionMethod · 0.50
read_expert_bodyMethod · 0.50
read_sectionMethod · 0.50
read_expert_bodyMethod · 0.50

Calls 1

stringFunction · 0.50

Tested by

no test coverage detected