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

Function search_scratch_close

src/mcp/mcp.c:9775–9792  ·  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

9773 * exit from handle_search_code can call it unconditionally. rmdir succeeding is
9774 * itself the proof nothing was left inside. */
9775static void search_scratch_close(search_scratch_t *scratch) {
9776 if (scratch->filelist) {
9777 (void)fclose(scratch->filelist);
9778 scratch->filelist = NULL;
9779 }
9780 if (scratch->pattern_path[0] != '\0') {
9781 (void)cbm_unlink(scratch->pattern_path);
9782 scratch->pattern_path[0] = '\0';
9783 }
9784 if (scratch->filelist_path[0] != '\0') {
9785 (void)cbm_unlink(scratch->filelist_path);
9786 scratch->filelist_path[0] = '\0';
9787 }
9788 if (scratch->dir[0] != '\0') {
9789 (void)cbm_rmdir(scratch->dir);
9790 scratch->dir[0] = '\0';
9791 }
9792}
9793
9794/* Open the scratch directory, write `pattern` to the grep -f file, and leave the
9795 * file list open for write_scoped_filelist. Returns true on success; on failure

Callers 3

search_scratch_openFunction · 0.85
search_code_scan_errorFunction · 0.85
handle_search_codeFunction · 0.85

Calls 2

cbm_unlinkFunction · 0.85
cbm_rmdirFunction · 0.85

Tested by

no test coverage detected