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

Function cbm_copy_binary_to_target

src/cli/cli.c:384–395  ·  view source on GitHub ↗

Copy the running binary into the canonical install target, preserving the * executable bit. When src and dst are the same on-disk file the copy is * skipped: cbm_copy_file opens dst "wb" before reading src, so copying a file * onto itself would truncate it to zero. Returns 0 on success or skip, * CLI_ERR on failure. Exposed (non-static) as the regression surface for the * `install --force` bi

Source from the content-addressed store, hash-verified

382 * CLI_ERR on failure. Exposed (non-static) as the regression surface for the
383 * `install --force` binary-swap bug (#472). */
384int cbm_copy_binary_to_target(const char *src, const char *dst) {
385 if (cbm_same_file(src, dst)) {
386 return 0; /* already in place — nothing to copy */
387 }
388 if (cbm_copy_file(src, dst) != 0) {
389 return CLI_ERR;
390 }
391#ifndef _WIN32
392 (void)chmod(dst, CLI_OCTAL_PERM);
393#endif
394 return 0;
395}
396
397/* Replace a binary file. Unlinks the old file first (handles read-only and
398 * running binaries on Unix where unlink succeeds on open files). On all

Callers 2

cbm_cmd_installFunction · 0.85
test_cli.cFile · 0.85

Calls 2

cbm_same_fileFunction · 0.85
cbm_copy_fileFunction · 0.85

Tested by

no test coverage detected