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

Function mcp_read_file_bytes

tests/test_mcp.c:496–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496static unsigned char *mcp_read_file_bytes(const char *path, long *out_len) {
497 if (!out_len) {
498 return NULL;
499 }
500 *out_len = 0;
501 FILE *fp = cbm_fopen(path, "rb");
502 if (!fp) {
503 return NULL;
504 }
505 if (fseek(fp, 0, SEEK_END) != 0) {
506 fclose(fp);
507 return NULL;
508 }
509 long size = ftell(fp);
510 if (size < 0 || fseek(fp, 0, SEEK_SET) != 0) {
511 fclose(fp);
512 return NULL;
513 }
514 unsigned char *bytes = malloc(size > 0 ? (size_t)size : 1);
515 if (!bytes) {
516 fclose(fp);
517 return NULL;
518 }
519 size_t read_count = fread(bytes, 1, (size_t)size, fp);
520 fclose(fp);
521 if (read_count != (size_t)size) {
522 free(bytes);
523 return NULL;
524 }
525 *out_len = size;
526 return bytes;
527}
528
529static bool mcp_file_matches_snapshot(const char *path, const unsigned char *expected,
530 long expected_len) {

Callers 2

test_mcp.cFile · 0.85

Calls 2

cbm_fopenFunction · 0.85
freadFunction · 0.85

Tested by

no test coverage detected