1
10
13
14
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
129
130
131
133
134
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
156
157
158
159
160
161
162
163
164
165
166
167
168
175
176
177
178
179
180
181
182
183
185
186
187
188
189
190
191
192
193
194
195
196
197
203
204
205
211
212
213
214
215
216
217
218
219
220
222
223
224
230
231
232
263
267
268
270
271
272
273
274
275
276
277
278
279
283
284
285
289
290
291
295
296
297
298
299
300
301
305
309
310
319
320
321
322
323
327
328
329
333
334
335
336
337
338
339
340
344
345
346
347
348
349
351
352
353
354
355
356
367
378
379
380
384
385
386
387
391
392
393
394
395
396
397
401
402
403
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
427
428
429
430
431
432
433
434
435
436
437
456
457
458
459
460
461
465
466
467
468
472
473
474
475
479
492
493
494
495
496
497
498
499
500
501
...
...
...
#define FX_SOURCE_CODE
#include "fx_api.h"
#include "fx_unicode.h"
#include "fx_utility.h"
#ifndef FX_NO_LOCAL_PATH
FX_LOCAL_PATH_SETUP
#endif
/* ... */
UCHAR _fx_unicode_temp_long_file_name[FX_MAX_LONG_NAME_LEN];
UCHAR _fx_unicode_search_name[FX_MAX_LONG_NAME_LEN * 2];
...
...
UINT _fx_unicode_directory_search(FX_MEDIA *media_ptr, FX_DIR_ENTRY *entry_ptr,
UCHAR *short_name, ULONG short_name_buffer_length,
UCHAR *unicode_name, ULONG *unicode_name_length, ULONG unicode_name_buffer_length)
{
ULONG i, j;
UINT status, found;
ULONG cluster, next_cluster = 0;
ULONG directory_size;
FX_DIR_ENTRY search_dir;
FX_DIR_ENTRY *search_dir_ptr;
ULONG unicode_search_length;
ULONG local_unicode_name_length;
CHAR unicode_to_short_name[13];
CHAR *short_name_ptr;
local_unicode_name_length = *unicode_name_length;
#ifndef FX_MEDIA_STATISTICS_DISABLE
media_ptr -> fx_media_directory_searches++;/* ... */
#endif
/* ... */
/* ... */
#ifndef FX_NO_LOCAL_PATH
if (_tx_thread_current_ptr -> tx_thread_filex_ptr)
{
if (((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_directory.fx_dir_entry_name[0])
{
search_dir = ((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_directory;
search_dir_ptr = &search_dir;
}if (((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_directory.fx_dir_entry_name[0]) { ... }
else
{
search_dir_ptr = FX_NULL;
}else { ... }
}if (_tx_thread_current_ptr -> tx_thread_filex_ptr) { ... }
else/* ... */
#endif
if (media_ptr -> fx_media_default_path.fx_path_directory.fx_dir_entry_name[0])
{
search_dir = media_ptr -> fx_media_default_path.fx_path_directory;
search_dir_ptr = &search_dir;
}else if (media_ptr -> fx_media_default_path.fx_path_directory.fx_dir_entry_name[0]) { ... }
else
{
/* ... */
search_dir_ptr = FX_NULL;
}else { ... }
if (search_dir_ptr)
{
search_dir_ptr -> fx_dir_entry_last_search_cluster = 0;
/* ... */
i = 0;
cluster = search_dir_ptr -> fx_dir_entry_cluster;
while ((cluster >= FX_FAT_ENTRY_START) && (cluster < media_ptr -> fx_media_fat_reserved))
{
i++;
status = _fx_utility_FAT_entry_read(media_ptr, cluster, &next_cluster);
if (status != FX_SUCCESS)
{
return(status);
}if (status != FX_SUCCESS) { ... }
if ((cluster == next_cluster) || (i > media_ptr -> fx_media_total_clusters))
{
return(FX_FAT_READ_ERROR);
}if ((cluster == next_cluster) || (i > media_ptr -> fx_media_total_clusters)) { ... }
cluster = next_cluster;
}while ((cluster >= FX_FAT_ENTRY_START) && (cluster < media_ptr -> fx_media_fat_reserved)) { ... }
directory_size = (((ULONG)media_ptr -> fx_media_bytes_per_sector) *
((ULONG)media_ptr -> fx_media_sectors_per_cluster) * i) /
(ULONG)FX_DIR_ENTRY_SIZE;
/* ... */
search_dir_ptr -> fx_dir_entry_file_size = directory_size;
}if (search_dir_ptr) { ... }
else
{
directory_size = (ULONG)media_ptr -> fx_media_root_directory_entries;
}else { ... }
if (short_name[0] == 0)
{
if (local_unicode_name_length <= 13)
{
for (j = 0; j < local_unicode_name_length; j++)
{
if ((unicode_name[j * 2] <= 0x7F) && (unicode_name[j * 2 + 1] == 0))
{
unicode_to_short_name[j] = (CHAR)unicode_name[j * 2];
if ((unicode_to_short_name[j] >= 'a') && (unicode_to_short_name[j] <= 'z'))
{
unicode_to_short_name[j] = (CHAR)((INT)unicode_to_short_name[j] - 0x20);
}if ((unicode_to_short_name[j] >= 'a') && (unicode_to_short_name[j] <= 'z')) { ... }
}if ((unicode_name[j * 2] <= 0x7F) && (unicode_name[j * 2 + 1] == 0)) { ... }
else
{
unicode_to_short_name[0] = 0;
break;
}else { ... }
}for (j = 0; j < local_unicode_name_length; j++) { ... }
}if (local_unicode_name_length <= 13) { ... }
else
{
unicode_to_short_name[0] = 0;
}else { ... }
}if (short_name[0] == 0) { ... }
else
{
unicode_to_short_name[0] = 0;
}else { ... }
/* ... */
i = 0;
do
{
status = _fx_unicode_directory_entry_read(media_ptr, search_dir_ptr, &i, entry_ptr, &_fx_unicode_search_name[0], &unicode_search_length);
i++;
if (status != FX_SUCCESS)
{
return(status);
}if (status != FX_SUCCESS) { ... }
if (((UCHAR)entry_ptr -> fx_dir_entry_name[0] == (UCHAR)FX_DIR_ENTRY_FREE) && (entry_ptr -> fx_dir_entry_short_name[0] == 0))
{
continue;
}if (((UCHAR)entry_ptr -> fx_dir_entry_name[0] == (UCHAR)FX_DIR_ENTRY_FREE) && (entry_ptr -> fx_dir_entry_short_name[0] == 0)) { ... }
if ((UCHAR)entry_ptr -> fx_dir_entry_name[0] == (UCHAR)FX_DIR_ENTRY_DONE)
{
break;
}if ((UCHAR)entry_ptr -> fx_dir_entry_name[0] == (UCHAR)FX_DIR_ENTRY_DONE) { ... }
if (unicode_to_short_name[0])
{
if (entry_ptr -> fx_dir_entry_short_name[0])
{
short_name_ptr = entry_ptr -> fx_dir_entry_short_name;
}if (entry_ptr -> fx_dir_entry_short_name[0]) { ... }
else
{
short_name_ptr = entry_ptr -> fx_dir_entry_name;
}else { ... }
for (j = 0; j < local_unicode_name_length; j++)
{
if (short_name_ptr[j] != unicode_to_short_name[j])
{
break;
}if (short_name_ptr[j] != unicode_to_short_name[j]) { ... }
}for (j = 0; j < local_unicode_name_length; j++) { ... }
if (j == local_unicode_name_length)
{
if (short_name_buffer_length > 13)
{
short_name_buffer_length = 13;
}if (short_name_buffer_length > 13) { ... }
for (j = 0; j < short_name_buffer_length; j++)
{
short_name[j] = (UCHAR)short_name_ptr[j];
}for (j = 0; j < short_name_buffer_length; j++) { ... }
return(FX_SUCCESS);
}if (j == local_unicode_name_length) { ... }
}if (unicode_to_short_name[0]) { ... }
if (unicode_search_length == 0)
{
continue;
}if (unicode_search_length == 0) { ... }
if (short_name[0])
{
/* ... */
found = FX_TRUE;
for (j = 0; j < 12; j++)
{
if (entry_ptr -> fx_dir_entry_short_name[0])
{
if (short_name[j] != (UCHAR)entry_ptr -> fx_dir_entry_short_name[j])
{
found = FX_FALSE;
break;
}if (short_name[j] != (UCHAR)entry_ptr -> fx_dir_entry_short_name[j]) { ... }
}if (entry_ptr -> fx_dir_entry_short_name[0]) { ... }
else
{
if (short_name[j] != (UCHAR)entry_ptr -> fx_dir_entry_name[j])
{
found = FX_FALSE;
break;
}if (short_name[j] != (UCHAR)entry_ptr -> fx_dir_entry_name[j]) { ... }
}else { ... }
if (short_name[j] == (UCHAR)FX_NULL)
{
break;
}if (short_name[j] == (UCHAR)FX_NULL) { ... }
}for (j = 0; j < 12; j++) { ... }
if ((found == FX_FALSE) || ((j == 12) && (short_name[12] != 0)))
{
continue;
}if ((found == FX_FALSE) || ((j == 12) && (short_name[12] != 0))) { ... }
*unicode_name_length = unicode_search_length;
if (unicode_name_buffer_length < (unicode_search_length + 1) * 2)
{
unicode_search_length = (unicode_name_buffer_length - 2) / 2;
}if (unicode_name_buffer_length < (unicode_search_length + 1) * 2) { ... }
for (j = 0; j < unicode_search_length * 2; j++)
{
unicode_name[j] = _fx_unicode_search_name[j];
}for (j = 0; j < unicode_search_length * 2; j++) { ... }
unicode_name[j] = (UCHAR)0;
unicode_name[j + 1] = (UCHAR)0;
return(FX_SUCCESS);
}if (short_name[0]) { ... }
else
{
if (unicode_search_length != local_unicode_name_length)
{
continue;
}if (unicode_search_length != local_unicode_name_length) { ... }
for (j = 0; j < (local_unicode_name_length * 2); j = j + 2)
{
if (unicode_name[j] != _fx_unicode_search_name[j])
{
if ((_fx_unicode_search_name[j + 1] == 0) && (unicode_name[j + 1] == 0))
{
if ((unicode_name[j]) >= 'a' && (unicode_name[j] <= 'z'))
{
if ((unicode_name[j] - 0x20) == _fx_unicode_search_name[j])
{
continue;
}if ((unicode_name[j] - 0x20) == _fx_unicode_search_name[j]) { ... }
}if ((unicode_name[j]) >= 'a' && (unicode_name[j] <= 'z')) { ... }
if ((_fx_unicode_search_name[j]) >= 'a' && (_fx_unicode_search_name[j] <= 'z'))
{
if ((_fx_unicode_search_name[j] - 0x20) == unicode_name[j])
{
continue;
}if ((_fx_unicode_search_name[j] - 0x20) == unicode_name[j]) { ... }
}if ((_fx_unicode_search_name[j]) >= 'a' && (_fx_unicode_search_name[j] <= 'z')) { ... }
}if ((_fx_unicode_search_name[j + 1] == 0) && (unicode_name[j + 1] == 0)) { ... }
break;
}if (unicode_name[j] != _fx_unicode_search_name[j]) { ... }
if (unicode_name[j + 1] != _fx_unicode_search_name[j + 1])
{
break;
}if (unicode_name[j + 1] != _fx_unicode_search_name[j + 1]) { ... }
}for (j = 0; j < (local_unicode_name_length * 2); j = j + 2) { ... }
if (j != (local_unicode_name_length * 2))
{
continue;
}if (j != (local_unicode_name_length * 2)) { ... }
if (short_name_buffer_length > 13)
{
short_name_buffer_length = 13;
}if (short_name_buffer_length > 13) { ... }
for (j = 0; j < short_name_buffer_length; j++)
{
if (entry_ptr -> fx_dir_entry_short_name[0])
{
short_name[j] = (UCHAR)entry_ptr -> fx_dir_entry_short_name[j];
}if (entry_ptr -> fx_dir_entry_short_name[0]) { ... }
else
{
short_name[j] = (UCHAR)entry_ptr -> fx_dir_entry_name[j];
}else { ... }
}for (j = 0; j < short_name_buffer_length; j++) { ... }
return(FX_SUCCESS);
}else { ... }
...} while (i < directory_size);
return(FX_NOT_FOUND);
}{ ... }