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:221–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219#endif
220
221bool cbm_path_for_file_api(const char *path, char *out, size_t out_size) {
222 if (!path || !out || out_size == 0) {
223 return false;
224 }
225#ifdef _WIN32
226 wchar_t *wide = cbm_path_to_wide(path);
227 char *narrow = wide ? cbm_wide_to_utf8(wide) : NULL;
228 free(wide);
229 if (!narrow) {
230 return false;
231 }
232 size_t needed = strlen(narrow);
233 bool fits = needed < out_size;
234 if (fits) {
235 memcpy(out, narrow, needed + 1U);
236 }
237 free(narrow);
238 return fits;
239#else
240 size_t needed = strlen(path);
241 if (needed >= out_size) {
242 return false;
243 }
244 memcpy(out, path, needed + 1U);
245 return true;
246#endif
247}
248
249/* ── mkstemp (Windows lacks it) ───────────────────────────────── */
250

Calls 2

cbm_path_to_wideFunction · 0.85
cbm_wide_to_utf8Function · 0.85

Tested by

no test coverage detected