Replace a binary transactionally, retaining the old target until the exact * staged bytes have been published and validated. */
| 1228 | /* Replace a binary transactionally, retaining the old target until the exact |
| 1229 | * staged bytes have been published and validated. */ |
| 1230 | int cbm_replace_binary(const char *path, const unsigned char *data, int len, int mode) { |
| 1231 | if (!path || !data || len <= 0) { |
| 1232 | return CLI_ERR; |
| 1233 | } |
| 1234 | cbm_activation_transaction_t *transaction = NULL; |
| 1235 | cbm_activation_transaction_status_t status = |
| 1236 | cbm_activation_transaction_stage_bytes(path, data, (size_t)len, &transaction); |
| 1237 | cli_binary_validator_t validator; |
| 1238 | if (status != CBM_ACTIVATION_TRANSACTION_OK || !transaction || |
| 1239 | !cli_activation_transaction_expected_build(transaction, &validator)) { |
| 1240 | (void)cli_activation_transaction_abort(&transaction); |
| 1241 | return CLI_ERR; |
| 1242 | } |
| 1243 | if (cli_activation_transaction_commit_validated(transaction, &validator, mode) != CLI_OK) { |
| 1244 | (void)cli_activation_transaction_abort(&transaction); |
| 1245 | return CLI_ERR; |
| 1246 | } |
| 1247 | return cli_activation_transaction_finalize_close(&transaction); |
| 1248 | } |
| 1249 | |
| 1250 | /* ── Skill file content (embedded) ────────────────────────────── */ |
| 1251 |
no test coverage detected