Replace a binary transactionally, retaining the old target until the exact * staged bytes have been published and validated. */
| 1199 | /* Replace a binary transactionally, retaining the old target until the exact |
| 1200 | * staged bytes have been published and validated. */ |
| 1201 | int cbm_replace_binary(const char *path, const unsigned char *data, int len, int mode) { |
| 1202 | if (!path || !data || len <= 0) { |
| 1203 | return CLI_ERR; |
| 1204 | } |
| 1205 | cbm_activation_transaction_t *transaction = NULL; |
| 1206 | cbm_activation_transaction_status_t status = |
| 1207 | cbm_activation_transaction_stage_bytes(path, data, (size_t)len, &transaction); |
| 1208 | cli_binary_validator_t validator; |
| 1209 | if (status != CBM_ACTIVATION_TRANSACTION_OK || !transaction || |
| 1210 | !cli_activation_transaction_expected_build(transaction, &validator)) { |
| 1211 | (void)cli_activation_transaction_abort(&transaction); |
| 1212 | return CLI_ERR; |
| 1213 | } |
| 1214 | if (cli_activation_transaction_commit_validated(transaction, &validator, mode) != CLI_OK) { |
| 1215 | (void)cli_activation_transaction_abort(&transaction); |
| 1216 | return CLI_ERR; |
| 1217 | } |
| 1218 | return cli_activation_transaction_finalize_close(&transaction); |
| 1219 | } |
| 1220 | |
| 1221 | /* ── Skill file content (embedded) ────────────────────────────── */ |
| 1222 |
no test coverage detected