| 1108 | } |
| 1109 | |
| 1110 | static cbm_activation_transaction_status_t activation_create_unique( |
| 1111 | const cbm_activation_transaction_t *transaction, const char *tag, char **path_out, |
| 1112 | char **name_out, activation_native_file_t *file_out, activation_file_identity_t *identity_out) { |
| 1113 | *path_out = NULL; |
| 1114 | *name_out = NULL; |
| 1115 | *file_out = ACTIVATION_INVALID_FILE; |
| 1116 | for (unsigned int attempt = 0; attempt < 1024U; attempt++) { |
| 1117 | char *candidate = activation_unique_path(transaction->directory_path, tag); |
| 1118 | if (!candidate) { |
| 1119 | return CBM_ACTIVATION_TRANSACTION_NO_MEMORY; |
| 1120 | } |
| 1121 | char *name = activation_path_name_copy(candidate); |
| 1122 | if (!name) { |
| 1123 | free(candidate); |
| 1124 | return CBM_ACTIVATION_TRANSACTION_NO_MEMORY; |
| 1125 | } |
| 1126 | activation_create_status_t created = |
| 1127 | activation_private_file_create(transaction, candidate, name, file_out, identity_out); |
| 1128 | if (created == ACTIVATION_CREATE_OK) { |
| 1129 | *path_out = candidate; |
| 1130 | *name_out = name; |
| 1131 | return CBM_ACTIVATION_TRANSACTION_OK; |
| 1132 | } |
| 1133 | free(candidate); |
| 1134 | free(name); |
| 1135 | if (created != ACTIVATION_CREATE_EXISTS) { |
| 1136 | return CBM_ACTIVATION_TRANSACTION_IO; |
| 1137 | } |
| 1138 | } |
| 1139 | return CBM_ACTIVATION_TRANSACTION_IO; |
| 1140 | } |
| 1141 | |
| 1142 | #ifdef _WIN32 |
| 1143 | static bool activation_external_snapshot_with_owner(const char *path, bool require_current_owner, |
no test coverage detected