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

Function search_scratch_close

src/mcp/mcp.c:9624–9641  ·  view source on GitHub ↗

Anchored cleanup: removes both scratch files and the private directory. Safe * to call more than once and on any partially-initialised scratch, so every * exit from handle_search_code can call it unconditionally. rmdir succeeding is * itself the proof nothing was left inside. */

Source from the content-addressed store, hash-verified

9622 * exit from handle_search_code can call it unconditionally. rmdir succeeding is
9623 * itself the proof nothing was left inside. */
9624static void search_scratch_close(search_scratch_t *scratch) {
9625 if (scratch->filelist) {
9626 (void)fclose(scratch->filelist);
9627 scratch->filelist = NULL;
9628 }
9629 if (scratch->pattern_path[0] != '\0') {
9630 (void)cbm_unlink(scratch->pattern_path);
9631 scratch->pattern_path[0] = '\0';
9632 }
9633 if (scratch->filelist_path[0] != '\0') {
9634 (void)cbm_unlink(scratch->filelist_path);
9635 scratch->filelist_path[0] = '\0';
9636 }
9637 if (scratch->dir[0] != '\0') {
9638 (void)cbm_rmdir(scratch->dir);
9639 scratch->dir[0] = '\0';
9640 }
9641}
9642
9643/* Open the scratch directory, write `pattern` to the grep -f file, and leave the
9644 * file list open for write_scoped_filelist. Returns true on success; on failure

Callers 2

search_scratch_openFunction · 0.85
handle_search_codeFunction · 0.85

Calls 2

cbm_unlinkFunction · 0.85
cbm_rmdirFunction · 0.85

Tested by

no test coverage detected