GCC Code Coverage Report


Directory: common/src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 111 / 0 / 111
Functions: 100.0% 1 / 0 / 1
Branches: 100.0% 220 / 0 / 220

fx_unicode_directory_search.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 #include "fx_utility.h"
31
32 #ifndef FX_NO_LOCAL_PATH
33 FX_LOCAL_PATH_SETUP
34 #endif
35
36
37 /* Define several Unicode working arrays... This keeps the data structures
38 off the local stack. */
39
40 UCHAR _fx_unicode_temp_long_file_name[FX_MAX_LONG_NAME_LEN];
41 UCHAR _fx_unicode_search_name[FX_MAX_LONG_NAME_LEN * 2];
42
43
44 /**************************************************************************/
45 /* */
46 /* FUNCTION RELEASE */
47 /* */
48 /* _fx_unicode_directory_search PORTABLE C */
49 /* 6.1 */
50 /* AUTHOR */
51 /* */
52 /* William E. Lamie, Microsoft Corporation */
53 /* */
54 /* DESCRIPTION */
55 /* */
56 /* This function searches for the specified unicode or short name. */
57 /* */
58 /* Note: The buffer of short_name and unicode_name must be valid to */
59 /* fill search result. When short_name is a zero length string, search */
60 /* is based on unicode string (terminated with NULL). If it's found */
61 /* the short name is written back to buffer of short_name. In this case*/
62 /* unicode_name_buffer_length is ignored and short_name_buffer_length */
63 /* must not be zero to specify the buffer length. If buffer is too */
64 /* smallfor the result, overflow characters and NULL-terminator are cut*/
65 /* off. When short_name is a valid string, search is based on */
66 /* short_name (terminated with NULL). If it's found the unicode name is*/
67 /* written back to buffer of unicode_name. In this case */
68 /* short_name_buffer_length is ignored and unicode_name_buffer_length */
69 /* must not be zero to specify the unicode buffer length. If buffer is */
70 /* too small for the result, overflow characters are cut off but */
71 /* NULL-terminator is kept. */
72 /* */
73 /* INPUT */
74 /* */
75 /* media_ptr Pointer to media */
76 /* short_name Pointer to short name */
77 /* short_name_buffer_length Buffer length for short name */
78 /* unicode_name Pointer to Unicode name */
79 /* unicode_name_length Unicode name length */
80 /* unicode_name_buffer_length Buffer length for Unicode name*/
81 /* */
82 /* OUTPUT */
83 /* */
84 /* Completion Status */
85 /* */
86 /* CALLS */
87 /* */
88 /* _fx_unicode_directory_entry_read Read a full unicode directory */
89 /* entry */
90 /* _fx_utility_FAT_entry_read Read a FAT entry */
91 /* */
92 /* CALLED BY */
93 /* */
94 /* Unicode Utilities */
95 /* */
96 /**************************************************************************/
97 7270 UINT _fx_unicode_directory_search(FX_MEDIA *media_ptr, FX_DIR_ENTRY *entry_ptr,
98 UCHAR *short_name, ULONG short_name_buffer_length,
99 UCHAR *unicode_name, ULONG *unicode_name_length, ULONG unicode_name_buffer_length)
100 {
101
102 ULONG i, j;
103 UINT status, found;
104 7270 ULONG cluster, next_cluster = 0;
105 ULONG directory_size;
106 FX_DIR_ENTRY search_dir;
107 FX_DIR_ENTRY *search_dir_ptr;
108 ULONG unicode_search_length;
109 ULONG local_unicode_name_length;
110 CHAR unicode_to_short_name[13];
111 CHAR *short_name_ptr;
112
113
114 /* Setup temp unicode name length. */
115 7270 local_unicode_name_length = *unicode_name_length;
116
117 #ifndef FX_MEDIA_STATISTICS_DISABLE
118
119 /* Increment the number of directory search requests. */
120 7270 media_ptr -> fx_media_directory_searches++;
121 #endif
122
123 /* Set the initial search directory to the current working
124 directory - if there is one. */
125
126 /* First check for a local path pointer stored in the thread control block. This
127 is only available in ThreadX Version 4 and above. */
128 #ifndef FX_NO_LOCAL_PATH
129
2/2
✓ Branch 2 → 3 taken 1174 times.
✓ Branch 2 → 6 taken 2793 times.
3967 if (_tx_thread_current_ptr -> tx_thread_filex_ptr)
130 {
131
132 /* Determine if the local directory is not the root directory. */
133
2/2
✓ Branch 3 → 4 taken 991 times.
✓ Branch 3 → 5 taken 183 times.
1174 if (((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_directory.fx_dir_entry_name[0])
134 {
135
136 /* Start at the current working directory of the media. */
137 991 search_dir = ((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_directory;
138
139 /* Set the internal pointer to the search directory as well. */
140 991 search_dir_ptr = &search_dir;
141 }
142 else
143 {
144
145 /* We are searching in the root directory. */
146 183 search_dir_ptr = FX_NULL;
147 }
148 }
149 else
150 #endif
151
4/4
✓ Branch 2 → 3 taken 919 times.
✓ Branch 2 → 4 taken 2384 times.
✓ Branch 6 → 7 taken 60 times.
✓ Branch 6 → 8 taken 2733 times.
6096 if (media_ptr -> fx_media_default_path.fx_path_directory.fx_dir_entry_name[0])
152 {
153
154 /* Start at the current working directory of the media. */
155 979 search_dir = media_ptr -> fx_media_default_path.fx_path_directory;
156
157 /* Set the internal pointer to the search directory as well. */
158 979 search_dir_ptr = &search_dir;
159 }
160 else
161 {
162
163 /* The current default directory is the root so just set the
164 search directory pointer to NULL. */
165 5117 search_dir_ptr = FX_NULL;
166 }
167
168 /* Calculate the directory size. */
169
4/4
✓ Branch 5 → 6 taken 919 times.
✓ Branch 5 → 17 taken 2384 times.
✓ Branch 9 → 10 taken 1051 times.
✓ Branch 9 → 21 taken 2916 times.
7270 if (search_dir_ptr)
170 {
171
172 /* Ensure that the search directory's last search cluster is cleared. */
173 1970 search_dir_ptr -> fx_dir_entry_last_search_cluster = 0;
174
175 /* Calculate the directory size by counting the allocated
176 clusters for it. */
177 1970 i = 0;
178 1970 cluster = search_dir_ptr -> fx_dir_entry_cluster;
179
8/8
✓ Branch 14 → 15 taken 38299 times.
✓ Branch 14 → 16 taken 8 times.
✓ Branch 15 → 7 taken 37402 times.
✓ Branch 15 → 16 taken 897 times.
✓ Branch 18 → 19 taken 47648 times.
✓ Branch 18 → 20 taken 20 times.
✓ Branch 19 → 11 taken 46632 times.
✓ Branch 19 → 20 taken 1016 times.
85975 while ((cluster >= FX_FAT_ENTRY_START) && (cluster < media_ptr -> fx_media_fat_reserved))
180 {
181
182 /* Increment the cluster count. */
183 84034 i++;
184
185 /* Read the next FAT entry. */
186 84034 status = _fx_utility_FAT_entry_read(media_ptr, cluster, &next_cluster);
187
188 /* Check the return status. */
189
4/4
✓ Branch 8 → 9 taken 6 times.
✓ Branch 8 → 10 taken 37396 times.
✓ Branch 12 → 13 taken 5 times.
✓ Branch 12 → 14 taken 46627 times.
84034 if (status != FX_SUCCESS)
190 {
191
192 /* Return the bad status. */
193 11 return(status);
194 }
195
196 /* Check for error situation. */
197
8/8
✓ Branch 10 → 11 taken 37392 times.
✓ Branch 10 → 12 taken 4 times.
✓ Branch 11 → 12 taken 4 times.
✓ Branch 11 → 13 taken 37388 times.
✓ Branch 14 → 15 taken 46622 times.
✓ Branch 14 → 16 taken 5 times.
✓ Branch 15 → 16 taken 5 times.
✓ Branch 15 → 17 taken 46617 times.
84023 if ((cluster == next_cluster) || (i > media_ptr -> fx_media_total_clusters))
198 {
199
200 /* Return the bad status. */
201 18 return(FX_FAT_READ_ERROR);
202 }
203
204 84005 cluster = next_cluster;
205 }
206
207 /* Now we can calculate the directory size. */
208 1941 directory_size = (((ULONG)media_ptr -> fx_media_bytes_per_sector) *
209 1941 ((ULONG)media_ptr -> fx_media_sectors_per_cluster) * i) /
210 (ULONG)FX_DIR_ENTRY_SIZE;
211
212 /* Also save this in the directory entry so we don't have to
213 calculate it later. */
214 1941 search_dir_ptr -> fx_dir_entry_file_size = directory_size;
215 }
216 else
217 {
218
219 /* Directory size is the number of entries in the root directory. */
220 5300 directory_size = (ULONG)media_ptr -> fx_media_root_directory_entries;
221 }
222
223 /* Determine if we are searching for a short file name or a unicode file name. */
224
4/4
✓ Branch 18 → 19 taken 3241 times.
✓ Branch 18 → 32 taken 48 times.
✓ Branch 22 → 23 taken 3892 times.
✓ Branch 22 → 36 taken 60 times.
7241 if (short_name[0] == 0)
225 {
226
227 /* If the unicode name fit into short name length, covert the Unicode to ASCII if possible. */
228
4/4
✓ Branch 19 → 20 taken 2665 times.
✓ Branch 19 → 31 taken 576 times.
✓ Branch 23 → 24 taken 3143 times.
✓ Branch 23 → 35 taken 749 times.
7133 if (local_unicode_name_length <= 13)
229 {
230
4/4
✓ Branch 29 → 21 taken 7223 times.
✓ Branch 29 → 30 taken 1833 times.
✓ Branch 33 → 25 taken 8498 times.
✓ Branch 33 → 34 taken 2140 times.
19694 for (j = 0; j < local_unicode_name_length; j++)
231 {
232
8/8
✓ Branch 21 → 22 taken 6775 times.
✓ Branch 21 → 27 taken 448 times.
✓ Branch 22 → 23 taken 6391 times.
✓ Branch 22 → 27 taken 384 times.
✓ Branch 25 → 26 taken 7938 times.
✓ Branch 25 → 31 taken 560 times.
✓ Branch 26 → 27 taken 7495 times.
✓ Branch 26 → 31 taken 443 times.
15721 if ((unicode_name[j * 2] <= 0x7F) && (unicode_name[j * 2 + 1] == 0))
233 {
234
235 13886 unicode_to_short_name[j] = (CHAR)unicode_name[j * 2];
236
8/8
✓ Branch 23 → 24 taken 2580 times.
✓ Branch 23 → 26 taken 3811 times.
✓ Branch 24 → 25 taken 2404 times.
✓ Branch 24 → 26 taken 176 times.
✓ Branch 27 → 28 taken 3216 times.
✓ Branch 27 → 30 taken 4279 times.
✓ Branch 28 → 29 taken 2996 times.
✓ Branch 28 → 30 taken 220 times.
13886 if ((unicode_to_short_name[j] >= 'a') && (unicode_to_short_name[j] <= 'z'))
237 {
238
239 /* Lower case, convert to upper case! */
240 5400 unicode_to_short_name[j] = (CHAR)((INT)unicode_to_short_name[j] - 0x20);
241 }
242 }
243 else
244 {
245 1835 unicode_to_short_name[0] = 0;
246 1835 break;
247 }
248 }
249 }
250 else
251 {
252 1325 unicode_to_short_name[0] = 0;
253 }
254 }
255 else
256 {
257 108 unicode_to_short_name[0] = 0;
258 }
259
260 /* Loop through entries in the directory. Yes, this is a
261 linear search! */
262 7241 i = 0;
263 do
264 {
265
266 /* Read an entry from the directory. */
267 86651 status = _fx_unicode_directory_entry_read(media_ptr, search_dir_ptr, &i, entry_ptr, &_fx_unicode_search_name[0], &unicode_search_length);
268 86651 i++;
269
270 /* Check for error status. */
271
4/4
✓ Branch 35 → 36 taken 44 times.
✓ Branch 35 → 37 taken 39184 times.
✓ Branch 39 → 40 taken 68 times.
✓ Branch 39 → 41 taken 47355 times.
86651 if (status != FX_SUCCESS)
272 {
273 112 return(status);
274 }
275
276 /* Determine if this is an empty entry. */
277
8/8
✓ Branch 37 → 38 taken 1218 times.
✓ Branch 37 → 40 taken 37966 times.
✓ Branch 38 → 39 taken 1150 times.
✓ Branch 38 → 40 taken 68 times.
✓ Branch 41 → 42 taken 1507 times.
✓ Branch 41 → 44 taken 45848 times.
✓ Branch 42 → 43 taken 1427 times.
✓ Branch 42 → 44 taken 80 times.
86539 if (((UCHAR)entry_ptr -> fx_dir_entry_name[0] == (UCHAR)FX_DIR_ENTRY_FREE) && (entry_ptr -> fx_dir_entry_short_name[0] == 0))
278 {
279 2577 continue;
280 }
281
282 /* Determine if this is the last directory entry. */
283
4/4
✓ Branch 40 → 41 taken 2092 times.
✓ Branch 40 → 42 taken 35942 times.
✓ Branch 44 → 45 taken 2466 times.
✓ Branch 44 → 46 taken 43462 times.
83962 if ((UCHAR)entry_ptr -> fx_dir_entry_name[0] == (UCHAR)FX_DIR_ENTRY_DONE)
284 {
285 4558 break;
286 }
287
288 /* Determine if there is a short name to match. */
289
4/4
✓ Branch 42 → 43 taken 13516 times.
✓ Branch 42 → 58 taken 22426 times.
✓ Branch 46 → 47 taken 15983 times.
✓ Branch 46 → 62 taken 27479 times.
79404 if (unicode_to_short_name[0])
290 {
291
292 /* Get the short name pointer. */
293
4/4
✓ Branch 43 → 44 taken 11702 times.
✓ Branch 43 → 45 taken 1814 times.
✓ Branch 47 → 48 taken 13976 times.
✓ Branch 47 → 49 taken 2007 times.
29499 if (entry_ptr -> fx_dir_entry_short_name[0])
294 {
295 25678 short_name_ptr = entry_ptr -> fx_dir_entry_short_name;
296 }
297 else
298 {
299 3821 short_name_ptr = entry_ptr -> fx_dir_entry_name;
300 }
301
302
4/4
✓ Branch 50 → 47 taken 13956 times.
✓ Branch 50 → 51 taken 12 times.
✓ Branch 54 → 51 taken 16533 times.
✓ Branch 54 → 55 taken 15 times.
30516 for (j = 0; j < local_unicode_name_length; j++)
303 {
304
305 /* Compare characters. */
306
4/4
✓ Branch 47 → 48 taken 13504 times.
✓ Branch 47 → 49 taken 452 times.
✓ Branch 51 → 52 taken 15968 times.
✓ Branch 51 → 53 taken 565 times.
30489 if (short_name_ptr[j] != unicode_to_short_name[j])
307 {
308 29472 break;
309 }
310 }
311
4/4
✓ Branch 51 → 52 taken 12 times.
✓ Branch 51 → 58 taken 13504 times.
✓ Branch 55 → 56 taken 15 times.
✓ Branch 55 → 62 taken 15968 times.
29499 if (j == local_unicode_name_length)
312 {
313
314 /* Only the 1st 13 bytes or the buffer length is copied, whichever is smaller. */
315
4/4
✓ Branch 52 → 53 taken 4 times.
✓ Branch 52 → 54 taken 8 times.
✓ Branch 56 → 57 taken 5 times.
✓ Branch 56 → 58 taken 10 times.
27 if (short_name_buffer_length > 13)
316 {
317 9 short_name_buffer_length = 13;
318 }
319
320 /* The names match, copy the short name into the destination. */
321
4/4
✓ Branch 56 → 55 taken 156 times.
✓ Branch 56 → 57 taken 12 times.
✓ Branch 60 → 59 taken 195 times.
✓ Branch 60 → 61 taken 15 times.
378 for (j = 0; j < short_name_buffer_length; j++)
322 {
323 351 short_name[j] = (UCHAR)short_name_ptr[j];
324 }
325
326 /* Return success to caller. */
327 27 return(FX_SUCCESS);
328 }
329 }
330
331 /* Determine if this is not a unicode name. */
332
4/4
✓ Branch 58 → 59 taken 1979 times.
✓ Branch 58 → 60 taken 33951 times.
✓ Branch 62 → 63 taken 2276 times.
✓ Branch 62 → 64 taken 41171 times.
79377 if (unicode_search_length == 0)
333 {
334 4255 continue;
335 }
336
337 /* Determine if we are searching for a short file name or a unicode file name. */
338
4/4
✓ Branch 60 → 61 taken 144 times.
✓ Branch 60 → 81 taken 33807 times.
✓ Branch 64 → 65 taken 180 times.
✓ Branch 64 → 85 taken 40991 times.
75122 if (short_name[0])
339 {
340
341 /* We have a short name and need a unicode name. Compare the short name against the short name in
342 the directory entry for a match. */
343 324 found = FX_TRUE;
344
4/4
✓ Branch 70 → 62 taken 476 times.
✓ Branch 70 → 71 taken 8 times.
✓ Branch 74 → 66 taken 595 times.
✓ Branch 74 → 75 taken 10 times.
1089 for (j = 0; j < 12; j++)
345 {
346
347 /* Compare characters... */
348
4/4
✓ Branch 62 → 63 taken 428 times.
✓ Branch 62 → 65 taken 48 times.
✓ Branch 66 → 67 taken 535 times.
✓ Branch 66 → 69 taken 60 times.
1071 if (entry_ptr -> fx_dir_entry_short_name[0])
349 {
350
351 /* Yes, the return name is in the short name field... compare against it! */
352
4/4
✓ Branch 63 → 64 taken 80 times.
✓ Branch 63 → 67 taken 348 times.
✓ Branch 67 → 68 taken 100 times.
✓ Branch 67 → 71 taken 435 times.
963 if (short_name[j] != (UCHAR)entry_ptr -> fx_dir_entry_short_name[j])
353 {
354
355 180 found = FX_FALSE;
356 180 break;
357 }
358 }
359 else
360 {
361
362 /* No, the return name is in the name field... compare against it! */
363
4/4
✓ Branch 65 → 66 taken 24 times.
✓ Branch 65 → 67 taken 24 times.
✓ Branch 69 → 70 taken 30 times.
✓ Branch 69 → 71 taken 30 times.
108 if (short_name[j] != (UCHAR)entry_ptr -> fx_dir_entry_name[j])
364 {
365
366 54 found = FX_FALSE;
367 54 break;
368 }
369 }
370
371 /* Are we done? */
372
4/4
✓ Branch 67 → 68 taken 32 times.
✓ Branch 67 → 69 taken 340 times.
✓ Branch 71 → 72 taken 40 times.
✓ Branch 71 → 73 taken 425 times.
837 if (short_name[j] == (UCHAR)FX_NULL)
373 {
374 72 break;
375 }
376 }
377
378 /* One final compare to see if we have a match. */
379
12/12
✓ Branch 71 → 72 taken 40 times.
✓ Branch 71 → 74 taken 104 times.
✓ Branch 72 → 73 taken 8 times.
✓ Branch 72 → 75 taken 32 times.
✓ Branch 73 → 74 taken 4 times.
✓ Branch 73 → 75 taken 4 times.
✓ Branch 75 → 76 taken 50 times.
✓ Branch 75 → 78 taken 130 times.
✓ Branch 76 → 77 taken 10 times.
✓ Branch 76 → 79 taken 40 times.
✓ Branch 77 → 78 taken 5 times.
✓ Branch 77 → 79 taken 5 times.
324 if ((found == FX_FALSE) || ((j == 12) && (short_name[12] != 0)))
380 {
381 243 continue;
382 }
383
384 /* A match was found so copy the unicode name and length and return. */
385 /* Copy the length. */
386 81 *unicode_name_length = unicode_search_length;
387
388 /* Check if the name fit in the buffer. */
389
4/4
✓ Branch 75 → 76 taken 4 times.
✓ Branch 75 → 77 taken 32 times.
✓ Branch 79 → 80 taken 5 times.
✓ Branch 79 → 81 taken 40 times.
81 if (unicode_name_buffer_length < (unicode_search_length + 1) * 2)
390 {
391 9 unicode_search_length = (unicode_name_buffer_length - 2) / 2;
392 }
393
394 /* Copy the unicode name. */
395
4/4
✓ Branch 79 → 78 taken 392 times.
✓ Branch 79 → 80 taken 36 times.
✓ Branch 83 → 82 taken 490 times.
✓ Branch 83 → 84 taken 45 times.
963 for (j = 0; j < unicode_search_length * 2; j++)
396 {
397
398 /* Copy one unicode character to the destination... */
399 882 unicode_name[j] = _fx_unicode_search_name[j];
400 }
401
402 /* Make sure there is a NULL in the destination. */
403 81 unicode_name[j] = (UCHAR)0;
404 81 unicode_name[j + 1] = (UCHAR)0;
405
406
407
408 /* Return successful completion. */
409 81 return(FX_SUCCESS);
410 }
411 else
412 {
413
414 /* Determine if this is the correct unicode name. */
415
4/4
✓ Branch 81 → 82 taken 7565 times.
✓ Branch 81 → 83 taken 26242 times.
✓ Branch 85 → 86 taken 8680 times.
✓ Branch 85 → 87 taken 32311 times.
74798 if (unicode_search_length != local_unicode_name_length)
416 {
417 16245 continue;
418 }
419
420 /* Compare the unicode search name with the requested unicode name. */
421
4/4
✓ Branch 99 → 84 taken 29828 times.
✓ Branch 99 → 100 taken 685 times.
✓ Branch 103 → 88 taken 36441 times.
✓ Branch 103 → 104 taken 834 times.
67788 for (j = 0; j < (local_unicode_name_length * 2); j = j + 2)
422 {
423
424 /* Compare bytes of each unicode name. */
425
4/4
✓ Branch 84 → 85 taken 25413 times.
✓ Branch 84 → 96 taken 4415 times.
✓ Branch 88 → 89 taken 31297 times.
✓ Branch 88 → 100 taken 5144 times.
66269 if (unicode_name[j] != _fx_unicode_search_name[j])
426 {
427
428 /* Not match, Check if the character is in ASCII range. */
429
8/8
✓ Branch 85 → 86 taken 24723 times.
✓ Branch 85 → 95 taken 690 times.
✓ Branch 86 → 87 taken 24466 times.
✓ Branch 86 → 95 taken 257 times.
✓ Branch 89 → 90 taken 30432 times.
✓ Branch 89 → 99 taken 865 times.
✓ Branch 90 → 91 taken 30110 times.
✓ Branch 90 → 99 taken 322 times.
56710 if ((_fx_unicode_search_name[j + 1] == 0) && (unicode_name[j + 1] == 0))
430 {
431
432 /* Check if it is case mismatch. */
433
8/8
✓ Branch 87 → 88 taken 10920 times.
✓ Branch 87 → 91 taken 13546 times.
✓ Branch 88 → 89 taken 4608 times.
✓ Branch 88 → 91 taken 6312 times.
✓ Branch 91 → 92 taken 13650 times.
✓ Branch 91 → 95 taken 16460 times.
✓ Branch 92 → 93 taken 5760 times.
✓ Branch 92 → 95 taken 7890 times.
54576 if ((unicode_name[j]) >= 'a' && (unicode_name[j] <= 'z'))
434 {
435
4/4
✓ Branch 89 → 90 taken 4 times.
✓ Branch 89 → 91 taken 4604 times.
✓ Branch 93 → 94 taken 5 times.
✓ Branch 93 → 95 taken 5755 times.
10368 if ((unicode_name[j] - 0x20) == _fx_unicode_search_name[j])
436 {
437 9 continue;
438 }
439 }
440
8/8
✓ Branch 91 → 92 taken 10002 times.
✓ Branch 91 → 95 taken 14460 times.
✓ Branch 92 → 93 taken 5250 times.
✓ Branch 92 → 95 taken 4752 times.
✓ Branch 95 → 96 taken 12501 times.
✓ Branch 95 → 99 taken 17604 times.
✓ Branch 96 → 97 taken 6561 times.
✓ Branch 96 → 99 taken 5940 times.
54567 if ((_fx_unicode_search_name[j]) >= 'a' && (_fx_unicode_search_name[j] <= 'z'))
441 {
442
4/4
✓ Branch 93 → 94 taken 4 times.
✓ Branch 93 → 95 taken 5246 times.
✓ Branch 97 → 98 taken 5 times.
✓ Branch 97 → 99 taken 6556 times.
11811 if ((_fx_unicode_search_name[j] - 0x20) == unicode_name[j])
443 {
444 9 continue;
445 }
446 }
447 }
448
449 56692 break;
450 }
451
452 /* Compare the next byte. */
453
4/4
✓ Branch 96 → 97 taken 152 times.
✓ Branch 96 → 98 taken 4263 times.
✓ Branch 100 → 101 taken 190 times.
✓ Branch 100 → 102 taken 4954 times.
9559 if (unicode_name[j + 1] != _fx_unicode_search_name[j + 1])
454 {
455 342 break;
456 }
457 }
458
459 /* Determine if the names do not match. */
460
4/4
✓ Branch 100 → 101 taken 25557 times.
✓ Branch 100 → 102 taken 685 times.
✓ Branch 104 → 105 taken 31477 times.
✓ Branch 104 → 106 taken 834 times.
58553 if (j != (local_unicode_name_length * 2))
461 {
462 57034 continue;
463 }
464
465 /* Otherwise, the names match, copy the short name into the destination. */
466 /* Only the 1st 13 bytes or the buffer length is copied, whichever is smaller. */
467
4/4
✓ Branch 102 → 103 taken 4 times.
✓ Branch 102 → 104 taken 681 times.
✓ Branch 106 → 107 taken 5 times.
✓ Branch 106 → 108 taken 829 times.
1519 if (short_name_buffer_length > 13)
468 {
469 9 short_name_buffer_length = 13;
470 }
471
4/4
✓ Branch 109 → 105 taken 8905 times.
✓ Branch 109 → 110 taken 685 times.
✓ Branch 113 → 109 taken 10842 times.
✓ Branch 113 → 114 taken 834 times.
21266 for (j = 0; j < short_name_buffer_length; j++)
472 {
473
474 /* Copy a character. */
475
4/4
✓ Branch 105 → 106 taken 6617 times.
✓ Branch 105 → 107 taken 2288 times.
✓ Branch 109 → 110 taken 8086 times.
✓ Branch 109 → 111 taken 2756 times.
19747 if (entry_ptr -> fx_dir_entry_short_name[0])
476 {
477 14703 short_name[j] = (UCHAR)entry_ptr -> fx_dir_entry_short_name[j];
478 }
479 else
480 {
481 5044 short_name[j] = (UCHAR)entry_ptr -> fx_dir_entry_name[j];
482 }
483 }
484
485 /* Return success to caller. */
486 1519 return(FX_SUCCESS);
487 }
488
4/4
✓ Branch 111 → 112 taken 35939 times.
✓ Branch 111 → 113 taken 420 times.
✓ Branch 115 → 116 taken 43471 times.
✓ Branch 115 → 117 taken 524 times.
80354 } while (i < directory_size);
489
490 /* Return not found. */
491 5502 return(FX_NOT_FOUND);
492 }
493
494