GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_unicode_short_name_get_extended.c Lines: 11 11 100.0 %
Date: 2024-01-10 21:53:23 Branches: 2 2 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_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
/*  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
107
UINT  _fx_unicode_short_name_get_extended(FX_MEDIA *media_ptr, UCHAR *source_unicode_name, ULONG source_unicode_length,
77
                                 CHAR *destination_short_name, ULONG short_name_buffer_length)
78
{
79
80
UINT         status;
81
ULONG        temp_unicode_length;
82
FX_DIR_ENTRY dir_entry;
83
84
85
    /* Setup pointer to media name buffer.  */
86
107
    dir_entry.fx_dir_entry_name =  media_ptr -> fx_media_name_buffer + FX_MAX_LONG_NAME_LEN;
87
88
    /* Clear the short name string.  */
89
107
    dir_entry.fx_dir_entry_short_name[0] =  0;
90
91
    /* Check the media to make sure it is open.  */
92
107
    if (media_ptr -> fx_media_id != FX_MEDIA_ID)
93
    {
94
95
        /* Return the media not opened error.  */
96
2
        return(FX_MEDIA_NOT_OPEN);
97
    }
98
99
#ifdef FX_ENABLE_EXFAT
100
    /* Check if media format is exFAT.  */
101
    if (media_ptr -> fx_media_FAT_type == FX_exFAT)
102
    {
103
104
        /* Return the not implemented error.  */
105
        return(FX_NOT_IMPLEMENTED);
106
    }
107
#endif
108
109
    /* Null terminate the short return name.  */
110
105
    destination_short_name[0] =  (UCHAR)0;
111
112
    /* Setup temporary unicode name length for search call.  */
113
105
    temp_unicode_length =  source_unicode_length;
114
115
    /* If trace is enabled, insert this event into the trace buffer.  */
116
    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)
117
118
    /* Protect against other threads accessing the media.  */
119
105
    FX_PROTECT
120
121
    /* Search the system for the supplied short name and return the unicode name if there is a match.  */
122
105
    status =  _fx_unicode_directory_search(media_ptr, &dir_entry, (UCHAR *)destination_short_name, short_name_buffer_length, source_unicode_name, &temp_unicode_length, 0);
123
124
    /* Release media protection.  */
125
105
    FX_UNPROTECT
126
127
    /* Return successful completion status.  */
128
105
    return(status);
129
}
130