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

Source from the content-addressed store, hash-verified

205#endif
206
207bool cbm_path_for_file_api(const char *path, char *out, size_t out_size) {
208 if (!path || !out || out_size == 0) {
209 return false;
210 }
211#ifdef _WIN32
212 wchar_t *wide = cbm_path_to_wide(path);
213 char *narrow = wide ? cbm_wide_to_utf8(wide) : NULL;
214 free(wide);
215 if (!narrow) {
216 return false;
217 }
218 size_t needed = strlen(narrow);
219 bool fits = needed < out_size;
220 if (fits) {
221 memcpy(out, narrow, needed + 1U);
222 }
223 free(narrow);
224 return fits;
225#else
226 size_t needed = strlen(path);
227 if (needed >= out_size) {
228 return false;
229 }
230 memcpy(out, path, needed + 1U);
231 return true;
232#endif
233}
234
235/* ── mkstemp (Windows lacks it) ───────────────────────────────── */
236

Calls 2

cbm_path_to_wideFunction · 0.85
cbm_wide_to_utf8Function · 0.85

Tested by

no test coverage detected