fxe_unicode_directory_rename.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************************************************** | ||
| 2 | * Copyright (c) 2024 Microsoft Corporation | ||
| 3 | * Copyright (c) 2026-present Eclipse ThreadX contributors | ||
| 4 | * | ||
| 5 | * This program and the accompanying materials are made available under the | ||
| 6 | * terms of the MIT License which is available at | ||
| 7 | * https://opensource.org/licenses/MIT. | ||
| 8 | * | ||
| 9 | * SPDX-License-Identifier: MIT | ||
| 10 | **************************************************************************/ | ||
| 11 | |||
| 12 | |||
| 13 | /**************************************************************************/ | ||
| 14 | /**************************************************************************/ | ||
| 15 | /** */ | ||
| 16 | /** FileX Component */ | ||
| 17 | /** */ | ||
| 18 | /** Unicode */ | ||
| 19 | /** */ | ||
| 20 | /**************************************************************************/ | ||
| 21 | /**************************************************************************/ | ||
| 22 | |||
| 23 | #define FX_SOURCE_CODE | ||
| 24 | |||
| 25 | |||
| 26 | /* Include necessary system files. */ | ||
| 27 | |||
| 28 | #include "fx_api.h" | ||
| 29 | #include "fx_unicode.h" | ||
| 30 | |||
| 31 | |||
| 32 | FX_CALLER_CHECKING_EXTERNS | ||
| 33 | |||
| 34 | |||
| 35 | /**************************************************************************/ | ||
| 36 | /* */ | ||
| 37 | /* FUNCTION RELEASE */ | ||
| 38 | /* */ | ||
| 39 | /* _fxe_unicode_directory_rename PORTABLE C */ | ||
| 40 | /* 6.1 */ | ||
| 41 | /* AUTHOR */ | ||
| 42 | /* */ | ||
| 43 | /* William E. Lamie, Microsoft Corporation */ | ||
| 44 | /* */ | ||
| 45 | /* DESCRIPTION */ | ||
| 46 | /* */ | ||
| 47 | /* This function checks for errors in the Unicode directory rename */ | ||
| 48 | /* service. */ | ||
| 49 | /* */ | ||
| 50 | /* INPUT */ | ||
| 51 | /* */ | ||
| 52 | /* media_ptr Pointer to media */ | ||
| 53 | /* old_unicode_name Pointer to old unicode name */ | ||
| 54 | /* old_unicode_length Old unicode name length */ | ||
| 55 | /* new_unicode_name Pointer to new unicode name */ | ||
| 56 | /* new_unicode_length Old unicode name length */ | ||
| 57 | /* new_short_name Pointer to new short name */ | ||
| 58 | /* */ | ||
| 59 | /* OUTPUT */ | ||
| 60 | /* */ | ||
| 61 | /* Completion Status */ | ||
| 62 | /* */ | ||
| 63 | /* CALLS */ | ||
| 64 | /* */ | ||
| 65 | /* _fx_unicode_directory_rename Actual Unicode directory */ | ||
| 66 | /* rename service */ | ||
| 67 | /* */ | ||
| 68 | /* CALLED BY */ | ||
| 69 | /* */ | ||
| 70 | /* Application Code */ | ||
| 71 | /* */ | ||
| 72 | /**************************************************************************/ | ||
| 73 | 5994 | UINT _fxe_unicode_directory_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length, | |
| 74 | UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name) | ||
| 75 | { | ||
| 76 | |||
| 77 | UINT status, i; | ||
| 78 | |||
| 79 | |||
| 80 | /* Check for a NULL media or name pointers. */ | ||
| 81 |
8/8✓ Branch 2 → 3 taken 5970 times.
✓ Branch 2 → 8 taken 24 times.
✓ Branch 3 → 4 taken 5280 times.
✓ Branch 3 → 8 taken 690 times.
✓ Branch 4 → 5 taken 4590 times.
✓ Branch 4 → 8 taken 690 times.
✓ Branch 5 → 6 taken 3900 times.
✓ Branch 5 → 8 taken 690 times.
|
5994 | if ((media_ptr == FX_NULL) || (old_unicode_name == FX_NULL) || (old_unicode_length == 0) || |
| 82 |
4/4✓ Branch 6 → 7 taken 3210 times.
✓ Branch 6 → 8 taken 690 times.
✓ Branch 7 → 8 taken 690 times.
✓ Branch 7 → 9 taken 2520 times.
|
3900 | (new_unicode_name == FX_NULL) || (new_unicode_length == 0) || (new_short_name == FX_NULL)) |
| 83 | { | ||
| 84 | 3474 | return(FX_PTR_ERROR); | |
| 85 | } | ||
| 86 | |||
| 87 | /* Check for a valid caller. */ | ||
| 88 |
6/6✓ Branch 9 → 10 taken 1605 times.
✓ Branch 9 → 12 taken 690 times.
✓ Branch 10 → 11 taken 915 times.
✓ Branch 10 → 12 taken 690 times.
✓ Branch 11 → 12 taken 690 times.
✓ Branch 11 → 13 taken 225 times.
|
2295 | FX_CALLER_CHECKING_CODE |
| 89 | |||
| 90 | /* Check unicode zero in old_unicode_name */ | ||
| 91 |
4/4✓ Branch 14 → 10 taken 875 times.
✓ Branch 14 → 15 taken 221 times.
✓ Branch 18 → 14 taken 875 times.
✓ Branch 18 → 19 taken 221 times.
|
2192 | for (i = 0; i < (old_unicode_length << 1); i += 2) |
| 92 | { | ||
| 93 |
8/8✓ Branch 10 → 11 taken 12 times.
✓ Branch 10 → 13 taken 863 times.
✓ Branch 11 → 12 taken 4 times.
✓ Branch 11 → 13 taken 8 times.
✓ Branch 14 → 15 taken 12 times.
✓ Branch 14 → 17 taken 863 times.
✓ Branch 15 → 16 taken 4 times.
✓ Branch 15 → 17 taken 8 times.
|
1750 | if ((old_unicode_name[i] == 0) && (old_unicode_name[i + 1] == 0)) |
| 94 | { | ||
| 95 | 8 | return(FX_INVALID_NAME); | |
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | /* Check unicode zero in new_unicode_name */ | ||
| 100 |
4/4✓ Branch 20 → 16 taken 978 times.
✓ Branch 20 → 21 taken 217 times.
✓ Branch 24 → 20 taken 978 times.
✓ Branch 24 → 25 taken 217 times.
|
2390 | for (i = 0; i < (new_unicode_length << 1); i += 2) |
| 101 | { | ||
| 102 |
8/8✓ Branch 16 → 17 taken 8 times.
✓ Branch 16 → 19 taken 970 times.
✓ Branch 17 → 18 taken 4 times.
✓ Branch 17 → 19 taken 4 times.
✓ Branch 20 → 21 taken 8 times.
✓ Branch 20 → 23 taken 970 times.
✓ Branch 21 → 22 taken 4 times.
✓ Branch 21 → 23 taken 4 times.
|
1956 | if ((new_unicode_name[i] == 0) && (new_unicode_name[i + 1] == 0)) |
| 103 | { | ||
| 104 | 8 | return(FX_INVALID_NAME); | |
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | /* Call actual Unicode directory rename service. */ | ||
| 109 | 434 | status = _fx_unicode_directory_rename(media_ptr, old_unicode_name, old_unicode_length, new_unicode_name, new_unicode_length, new_short_name); | |
| 110 | |||
| 111 | /* Return status to the caller. */ | ||
| 112 | 416 | return(status); | |
| 113 | } | ||
| 114 | |||
| 115 |