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

Method open_model

engine/src/core/conversation_file.cpp:195–210  ·  view source on GitHub ↗

a model input: links followed (model folders are often linked)

Source from the content-addressed store, hash-verified

193 }
194 // a model input: links followed (model folders are often linked)
195 bool open_model(const std::string& path, uint64_t& size) {
196 std::wstring w;
197 if (!wide(path, w)) { refused_ = true; error_ = "the path is not valid UTF-8"; return false; }
198 h_ = CreateFileW(w.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
199 nullptr);
200 if (h_ == INVALID_HANDLE_VALUE) {
201 const DWORD code = GetLastError();
202 missing_ = code == ERROR_FILE_NOT_FOUND || code == ERROR_PATH_NOT_FOUND;
203 kind_ = win_kind(code); error_ = last_error(code);
204 return false;
205 }
206 LARGE_INTEGER s{};
207 if (!GetFileSizeEx(h_, &s)) { { const DWORD c_ = GetLastError(); kind_ = win_kind(c_); error_ = last_error(c_); } return false; }
208 size = (uint64_t) s.QuadPart;
209 return true;
210 }
211 bool is_open() const { return h_ != INVALID_HANDLE_VALUE; }
212 bool direct() const { return false; }
213 bool write_all(const uint8_t* p, size_t n) {

Callers 1

Calls 5

wideFunction · 0.85
win_kindFunction · 0.85
last_errorFunction · 0.85
errno_kindFunction · 0.85
openFunction · 0.50

Tested by

no test coverage detected