GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_unicode_name_get_extended.c Lines: 13 13 100.0 %
Date: 2024-03-11 05:15:45 Branches: 4 4 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** FileX Component                                                       */
16
/**                                                                       */
17
/**   Unicode                                                             */
18
/**                                                                       */
19
/**************************************************************************/
20
/**************************************************************************/
21
22
#define FX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "fx_api.h"
28
#include "fx_unicode.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _fx_unicode_name_get_extended                       PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    William E. Lamie, Microsoft Corporation                             */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function finds the unicode name associated with the supplied   */
44
/*    short 8.3 name.                                                     */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    media_ptr                             Pointer to media              */
49
/*    source_short_name                     Pointer to short file name    */
50
/*    destination_unicode_name              Pointer to destination name   */
51
/*    destination_unicode_length            Destination for name length   */
52
/*    unicode_name_buffer_length            Buffer length of unicode name */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    Completion Status                                                   */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _fx_unicode_directory_search          Search for unicode name       */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     William E. Lamie         Initial Version 6.0           */
71
/*  09-30-2020     William E. Lamie         Modified comment(s),          */
72
/*                                            resulting in version 6.1    */
73
/*                                                                        */
74
/**************************************************************************/
75
14
UINT  _fx_unicode_name_get_extended(FX_MEDIA *media_ptr, CHAR *source_short_name,
76
                           UCHAR *destination_unicode_name, ULONG *destination_unicode_length, ULONG unicode_name_buffer_length)
77
{
78
79
UINT                   status;
80
FX_DIR_ENTRY           dir_entry;
81
82
#ifdef TX_ENABLE_EVENT_TRACE
83
TX_TRACE_BUFFER_ENTRY *trace_event;
84
ULONG                  trace_timestamp;
85
#endif
86
87
88
    /* Setup pointer to media name buffer.  */
89
14
    dir_entry.fx_dir_entry_name =  media_ptr -> fx_media_name_buffer + FX_MAX_LONG_NAME_LEN;
90
91
    /* Clear the short name string.  */
92
14
    dir_entry.fx_dir_entry_short_name[0] =  0;
93
94
    /* Check the media to make sure it is open.  */
95
14
    if (media_ptr -> fx_media_id != FX_MEDIA_ID)
96
    {
97
98
        /* Return the media not opened error.  */
99
2
        return(FX_MEDIA_NOT_OPEN);
100
    }
101
102
103
    /* Set the destination unicode length to zero to indicate there is nothing in terms of a match.  */
104
12
    *destination_unicode_length =  0;
105
106
    /* If trace is enabled, insert this event into the trace buffer.  */
107
    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)
108
109
    /* Protect against other threads accessing the media.  */
110
12
    FX_PROTECT
111
112
    /* Search the system for the supplied short file name and return the unicode name if there is a match.  */
113
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);
114
115
    /* Determine if the search was successful.  */
116
12
    if (status != FX_SUCCESS)
117
    {
118
119
        /* Release media protection.  */
120
3
        FX_UNPROTECT
121
122
        /* Return the error code.  */
123
3
        return(status);
124
    }
125
126
    /* Release media protection.  */
127
9
    FX_UNPROTECT
128
129
    /* Update the trace event with the unicode length.  */
130
    FX_TRACE_EVENT_UPDATE(trace_event, trace_timestamp, FX_TRACE_UNICODE_NAME_GET, 0, 0, 0, *destination_unicode_length)
131
132
    /* Return successful completion status.  */
133
9
    return(FX_SUCCESS);
134
}
135