fx_unicode_name_get_extended.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 | /**************************************************************************/ | ||
| 33 | /* */ | ||
| 34 | /* FUNCTION RELEASE */ | ||
| 35 | /* */ | ||
| 36 | /* _fx_unicode_name_get_extended PORTABLE C */ | ||
| 37 | /* 6.1 */ | ||
| 38 | /* AUTHOR */ | ||
| 39 | /* */ | ||
| 40 | /* William E. Lamie, Microsoft Corporation */ | ||
| 41 | /* */ | ||
| 42 | /* DESCRIPTION */ | ||
| 43 | /* */ | ||
| 44 | /* This function finds the unicode name associated with the supplied */ | ||
| 45 | /* short 8.3 name. */ | ||
| 46 | /* */ | ||
| 47 | /* INPUT */ | ||
| 48 | /* */ | ||
| 49 | /* media_ptr Pointer to media */ | ||
| 50 | /* source_short_name Pointer to short file name */ | ||
| 51 | /* destination_unicode_name Pointer to destination name */ | ||
| 52 | /* destination_unicode_length Destination for name length */ | ||
| 53 | /* unicode_name_buffer_length Buffer length of unicode name */ | ||
| 54 | /* */ | ||
| 55 | /* OUTPUT */ | ||
| 56 | /* */ | ||
| 57 | /* Completion Status */ | ||
| 58 | /* */ | ||
| 59 | /* CALLS */ | ||
| 60 | /* */ | ||
| 61 | /* _fx_unicode_directory_search Search for unicode name */ | ||
| 62 | /* */ | ||
| 63 | /* CALLED BY */ | ||
| 64 | /* */ | ||
| 65 | /* Application Code */ | ||
| 66 | /* */ | ||
| 67 | /**************************************************************************/ | ||
| 68 | 126 | UINT _fx_unicode_name_get_extended(FX_MEDIA *media_ptr, CHAR *source_short_name, | |
| 69 | UCHAR *destination_unicode_name, ULONG *destination_unicode_length, ULONG unicode_name_buffer_length) | ||
| 70 | { | ||
| 71 | |||
| 72 | UINT status; | ||
| 73 | FX_DIR_ENTRY dir_entry; | ||
| 74 | |||
| 75 | #ifdef TX_ENABLE_EVENT_TRACE | ||
| 76 | TX_TRACE_BUFFER_ENTRY *trace_event; | ||
| 77 | ULONG trace_timestamp; | ||
| 78 | #endif | ||
| 79 | |||
| 80 | |||
| 81 | /* Setup pointer to media name buffer. */ | ||
| 82 | 126 | dir_entry.fx_dir_entry_name = media_ptr -> fx_media_name_buffer + FX_MAX_LONG_NAME_LEN; | |
| 83 | |||
| 84 | /* Clear the short name string. */ | ||
| 85 | 126 | dir_entry.fx_dir_entry_short_name[0] = 0; | |
| 86 | |||
| 87 | /* Check the media to make sure it is open. */ | ||
| 88 |
2/2✓ Branch 2 → 3 taken 18 times.
✓ Branch 2 → 4 taken 108 times.
|
126 | if (media_ptr -> fx_media_id != FX_MEDIA_ID) |
| 89 | { | ||
| 90 | |||
| 91 | /* Return the media not opened error. */ | ||
| 92 | 18 | return(FX_MEDIA_NOT_OPEN); | |
| 93 | } | ||
| 94 | |||
| 95 | |||
| 96 | /* Set the destination unicode length to zero to indicate there is nothing in terms of a match. */ | ||
| 97 | 108 | *destination_unicode_length = 0; | |
| 98 | |||
| 99 | /* If trace is enabled, insert this event into the trace buffer. */ | ||
| 100 | FX_TRACE_IN_LINE_INSERT(FX_TRACE_UNICODE_NAME_GET, media_ptr, source_short_name, destination_unicode_name, 0, FX_TRACE_FILE_EVENTS, &trace_event, &trace_timestamp) | ||
| 101 | |||
| 102 | /* Protect against other threads accessing the media. */ | ||
| 103 | 60 | FX_PROTECT | |
| 104 | |||
| 105 | /* Search the system for the supplied short file name and return the unicode name if there is a match. */ | ||
| 106 | 108 | status = _fx_unicode_directory_search(media_ptr, &dir_entry, (UCHAR *)source_short_name, 0, destination_unicode_name, destination_unicode_length, unicode_name_buffer_length); | |
| 107 | |||
| 108 | /* Determine if the search was successful. */ | ||
| 109 |
4/4✓ Branch 5 → 6 taken 12 times.
✓ Branch 5 → 7 taken 36 times.
✓ Branch 6 → 7 taken 15 times.
✓ Branch 6 → 9 taken 45 times.
|
108 | if (status != FX_SUCCESS) |
| 110 | { | ||
| 111 | |||
| 112 | /* Release media protection. */ | ||
| 113 | 15 | FX_UNPROTECT | |
| 114 | |||
| 115 | /* Return the error code. */ | ||
| 116 | 27 | return(status); | |
| 117 | } | ||
| 118 | |||
| 119 | /* Release media protection. */ | ||
| 120 | 45 | FX_UNPROTECT | |
| 121 | |||
| 122 | /* Update the trace event with the unicode length. */ | ||
| 123 | FX_TRACE_EVENT_UPDATE(trace_event, trace_timestamp, FX_TRACE_UNICODE_NAME_GET, 0, 0, 0, *destination_unicode_length) | ||
| 124 | |||
| 125 | /* Return successful completion status. */ | ||
| 126 | 81 | return(FX_SUCCESS); | |
| 127 | } | ||
| 128 | |||
| 129 |