MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_path_for_file_api

Function cbm_path_for_file_api

src/foundation/compat.c:178–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176#endif
177
178bool cbm_path_for_file_api(const char *path, char *out, size_t out_size) {
179 if (!path || !out || out_size == 0) {
180 return false;
181 }
182#ifdef _WIN32
183 wchar_t *wide = cbm_path_to_wide(path);
184 char *narrow = wide ? cbm_wide_to_utf8(wide) : NULL;
185 free(wide);
186 if (!narrow) {
187 return false;
188 }
189 size_t needed = strlen(narrow);
190 bool fits = needed < out_size;
191 if (fits) {
192 memcpy(out, narrow, needed + 1U);
193 }
194 free(narrow);
195 return fits;
196#else
197 size_t needed = strlen(path);
198 if (needed >= out_size) {
199 return false;
200 }
201 memcpy(out, path, needed + 1U);
202 return true;
203#endif
204}
205
206/* ── mkstemp (Windows lacks it) ───────────────────────────────── */
207

Calls 2

cbm_path_to_wideFunction · 0.85
cbm_wide_to_utf8Function · 0.85

Tested by

no test coverage detected