| 1250 | } |
| 1251 | |
| 1252 | static cbm_activation_transaction_status_t activation_create_unique( |
| 1253 | const cbm_activation_transaction_t *transaction, const char *tag, char **path_out, |
| 1254 | char **name_out, activation_native_file_t *file_out, activation_file_identity_t *identity_out) { |
| 1255 | *path_out = NULL; |
| 1256 | *name_out = NULL; |
| 1257 | *file_out = ACTIVATION_INVALID_FILE; |
| 1258 | for (unsigned int attempt = 0; attempt < 1024U; attempt++) { |
| 1259 | char *candidate = activation_unique_path(transaction->directory_path, tag); |
| 1260 | if (!candidate) { |
| 1261 | return CBM_ACTIVATION_TRANSACTION_NO_MEMORY; |
| 1262 | } |
| 1263 | char *name = activation_path_name_copy(candidate); |
| 1264 | if (!name) { |
| 1265 | free(candidate); |
| 1266 | return CBM_ACTIVATION_TRANSACTION_NO_MEMORY; |
| 1267 | } |
| 1268 | activation_create_status_t created = |
| 1269 | activation_private_file_create(transaction, candidate, name, file_out, identity_out); |
| 1270 | if (created == ACTIVATION_CREATE_OK) { |
| 1271 | *path_out = candidate; |
| 1272 | *name_out = name; |
| 1273 | return CBM_ACTIVATION_TRANSACTION_OK; |
| 1274 | } |
| 1275 | free(candidate); |
| 1276 | free(name); |
| 1277 | if (created != ACTIVATION_CREATE_EXISTS) { |
| 1278 | return CBM_ACTIVATION_TRANSACTION_IO; |
| 1279 | } |
| 1280 | } |
| 1281 | return CBM_ACTIVATION_TRANSACTION_IO; |
| 1282 | } |
| 1283 | |
| 1284 | #ifdef _WIN32 |
| 1285 | static bool activation_external_snapshot_with_owner(const char *path, bool require_current_owner, |
no test coverage detected