fx_unicode_short_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_short_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 short name associated with the supplied */ | ||
| 45 | /* unicode name. */ | ||
| 46 | /* */ | ||
| 47 | /* INPUT */ | ||
| 48 | /* */ | ||
| 49 | /* media_ptr Pointer to media */ | ||
| 50 | /* source_unicode_name Pointer to unicode name */ | ||
| 51 | /* source_unicode_length Length of unicode name */ | ||
| 52 | /* destination_short_name Pointer to destination name */ | ||
| 53 | /* short_name_buffer_length Buffer length of short 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 | 1019 | UINT _fx_unicode_short_name_get_extended(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length, | |
| 69 | CHAR *destination_short_name, ULONG short_name_buffer_length) | ||
| 70 | { | ||
| 71 | |||
| 72 | UINT status; | ||
| 73 | ULONG temp_unicode_length; | ||
| 74 | FX_DIR_ENTRY dir_entry; | ||
| 75 | |||
| 76 | |||
| 77 | /* Setup pointer to media name buffer. */ | ||
| 78 | 1019 | dir_entry.fx_dir_entry_name = media_ptr -> fx_media_name_buffer + FX_MAX_LONG_NAME_LEN; | |
| 79 | |||
| 80 | /* Clear the short name string. */ | ||
| 81 | 1019 | dir_entry.fx_dir_entry_short_name[0] = 0; | |
| 82 | |||
| 83 | /* Check the media to make sure it is open. */ | ||
| 84 |
2/2✓ Branch 2 → 3 taken 18 times.
✓ Branch 2 → 4 taken 1001 times.
|
1019 | if (media_ptr -> fx_media_id != FX_MEDIA_ID) |
| 85 | { | ||
| 86 | |||
| 87 | /* Return the media not opened error. */ | ||
| 88 | 18 | return(FX_MEDIA_NOT_OPEN); | |
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 | /* Null terminate the short return name. */ | ||
| 93 | 1001 | destination_short_name[0] = (UCHAR)0; | |
| 94 | |||
| 95 | /* Setup temporary unicode name length for search call. */ | ||
| 96 | 1001 | temp_unicode_length = source_unicode_length; | |
| 97 | |||
| 98 | /* If trace is enabled, insert this event into the trace buffer. */ | ||
| 99 | FX_TRACE_IN_LINE_INSERT(FX_TRACE_UNICODE_SHORT_NAME_GET, media_ptr, source_unicode_name, source_unicode_length, destination_short_name, FX_TRACE_FILE_EVENTS, 0, 0) | ||
| 100 | |||
| 101 | /* Protect against other threads accessing the media. */ | ||
| 102 | 552 | FX_PROTECT | |
| 103 | |||
| 104 | /* Search the system for the supplied short name and return the unicode name if there is a match. */ | ||
| 105 | 1001 | status = _fx_unicode_directory_search(media_ptr, &dir_entry, (UCHAR *)destination_short_name, short_name_buffer_length, source_unicode_name, &temp_unicode_length, 0); | |
| 106 | |||
| 107 | /* Release media protection. */ | ||
| 108 | 552 | FX_UNPROTECT | |
| 109 | |||
| 110 | /* Return successful completion status. */ | ||
| 111 | 1001 | return(status); | |
| 112 | } | ||
| 113 | |||
| 114 |