GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_unicode_name_get_extended.c Lines: 13 13 100.0 %
Date: 2024-01-10 21:53:23 Branches: 4 4 100.0 %

Line Branch Exec Source
1
/**************************************************************************/
2
/*                                                                        */
3
/*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4
/*                                                                        */
5
/*       This software is licensed under the Microsoft Software License   */
6
/*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7
/*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8
/*       and in the root directory of this software.                      */
9
/*                                                                        */
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
/*  RELEASE HISTORY                                                       */
68
/*                                                                        */
69
/*    DATE              NAME                      DESCRIPTION             */
70
/*                                                                        */
71
/*  05-19-2020     William E. Lamie         Initial Version 6.0           */
72
/*  09-30-2020     William E. Lamie         Modified comment(s),          */
73
/*                                            resulting in version 6.1    */
74
/*                                                                        */
75
/**************************************************************************/
76
14
UINT  _fx_unicode_name_get_extended(FX_MEDIA *media_ptr, CHAR *source_short_name,
77
                           UCHAR *destination_unicode_name, ULONG *destination_unicode_length, ULONG unicode_name_buffer_length)
78
{
79
80
UINT                   status;
81
FX_DIR_ENTRY           dir_entry;
82
83
#ifdef TX_ENABLE_EVENT_TRACE
84
TX_TRACE_BUFFER_ENTRY *trace_event;
85
ULONG                  trace_timestamp;
86
#endif
87
88
89
    /* Setup pointer to media name buffer.  */
90
14
    dir_entry.fx_dir_entry_name =  media_ptr -> fx_media_name_buffer + FX_MAX_LONG_NAME_LEN;
91
92
    /* Clear the short name string.  */
93
14
    dir_entry.fx_dir_entry_short_name[0] =  0;
94
95
    /* Check the media to make sure it is open.  */
96
14
    if (media_ptr -> fx_media_id != FX_MEDIA_ID)
97
    {
98
99
        /* Return the media not opened error.  */
100
2
        return(FX_MEDIA_NOT_OPEN);
101
    }
102
103
#ifdef FX_ENABLE_EXFAT
104
    /* Check if media format is exFAT.  */
105
    if (media_ptr -> fx_media_FAT_type == FX_exFAT)
106
    {
107
108
        /* Return the not implemented error.  */
109
        return(FX_NOT_IMPLEMENTED);
110
    }
111
#endif
112
113
    /* Set the destination unicode length to zero to indicate there is nothing in terms of a match.  */
114
12
    *destination_unicode_length =  0;
115
116
    /* If trace is enabled, insert this event into the trace buffer.  */
117
    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)
118
119
    /* Protect against other threads accessing the media.  */
120
12
    FX_PROTECT
121
122
    /* Search the system for the supplied short file name and return the unicode name if there is a match.  */
123
12
    status =  _fx_unicode_directory_search(media_ptr, &dir_entry, (UCHAR *)source_short_name, 0, destination_unicode_name, destination_unicode_length, unicode_name_buffer_length);
124
125
    /* Determine if the search was successful.  */
126
12
    if (status != FX_SUCCESS)
127
    {
128
129
        /* Release media protection.  */
130
3
        FX_UNPROTECT
131
132
        /* Return the error code.  */
133
3
        return(status);
134
    }
135
136
    /* Release media protection.  */
137
9
    FX_UNPROTECT
138
139
    /* Update the trace event with the unicode length.  */
140
    FX_TRACE_EVENT_UPDATE(trace_event, trace_timestamp, FX_TRACE_UNICODE_NAME_GET, 0, 0, 0, *destination_unicode_length)
141
142
    /* Return successful completion status.  */
143
9
    return(FX_SUCCESS);
144
}
145