| 978 | } |
| 979 | |
| 980 | static cbm_activation_transaction_status_t activation_create_unique( |
| 981 | const cbm_activation_transaction_t *transaction, const char *tag, char **path_out, |
| 982 | char **name_out, activation_native_file_t *file_out, activation_file_identity_t *identity_out) { |
| 983 | *path_out = NULL; |
| 984 | *name_out = NULL; |
| 985 | *file_out = ACTIVATION_INVALID_FILE; |
| 986 | for (unsigned int attempt = 0; attempt < 1024U; attempt++) { |
| 987 | char *candidate = activation_unique_path(transaction->directory_path, tag); |
| 988 | if (!candidate) { |
| 989 | return CBM_ACTIVATION_TRANSACTION_NO_MEMORY; |
| 990 | } |
| 991 | char *name = activation_path_name_copy(candidate); |
| 992 | if (!name) { |
| 993 | free(candidate); |
| 994 | return CBM_ACTIVATION_TRANSACTION_NO_MEMORY; |
| 995 | } |
| 996 | activation_create_status_t created = |
| 997 | activation_private_file_create(transaction, candidate, name, file_out, identity_out); |
| 998 | if (created == ACTIVATION_CREATE_OK) { |
| 999 | *path_out = candidate; |
| 1000 | *name_out = name; |
| 1001 | return CBM_ACTIVATION_TRANSACTION_OK; |
| 1002 | } |
| 1003 | free(candidate); |
| 1004 | free(name); |
| 1005 | if (created != ACTIVATION_CREATE_EXISTS) { |
| 1006 | return CBM_ACTIVATION_TRANSACTION_IO; |
| 1007 | } |
| 1008 | } |
| 1009 | return CBM_ACTIVATION_TRANSACTION_IO; |
| 1010 | } |
| 1011 | |
| 1012 | #ifdef _WIN32 |
| 1013 | static bool activation_external_snapshot_with_owner(const char *path, bool require_current_owner, |
no test coverage detected