GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fxe_unicode_directory_rename.c Lines: 13 13 100.0 %
Date: 2024-01-10 21:53:23 Branches: 30 30 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
FX_CALLER_CHECKING_EXTERNS
33
34
35
/**************************************************************************/
36
/*                                                                        */
37
/*  FUNCTION                                               RELEASE        */
38
/*                                                                        */
39
/*    _fxe_unicode_directory_rename                       PORTABLE C      */
40
/*                                                           6.1          */
41
/*  AUTHOR                                                                */
42
/*                                                                        */
43
/*    William E. Lamie, Microsoft Corporation                             */
44
/*                                                                        */
45
/*  DESCRIPTION                                                           */
46
/*                                                                        */
47
/*    This function checks for errors in the Unicode directory rename     */
48
/*    service.                                                            */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    media_ptr                             Pointer to media              */
53
/*    old_unicode_name                      Pointer to old unicode name   */
54
/*    old_unicode_length                    Old unicode name length       */
55
/*    new_unicode_name                      Pointer to new unicode name   */
56
/*    new_unicode_length                    Old unicode name length       */
57
/*    new_short_name                        Pointer to new short name     */
58
/*                                                                        */
59
/*  OUTPUT                                                                */
60
/*                                                                        */
61
/*    Completion Status                                                   */
62
/*                                                                        */
63
/*  CALLS                                                                 */
64
/*                                                                        */
65
/*    _fx_unicode_directory_rename          Actual Unicode directory      */
66
/*                                            rename service              */
67
/*                                                                        */
68
/*  CALLED BY                                                             */
69
/*                                                                        */
70
/*    Application Code                                                    */
71
/*                                                                        */
72
/*  RELEASE HISTORY                                                       */
73
/*                                                                        */
74
/*    DATE              NAME                      DESCRIPTION             */
75
/*                                                                        */
76
/*  05-19-2020     William E. Lamie         Initial Version 6.0           */
77
/*  09-30-2020     William E. Lamie         Modified comment(s),          */
78
/*                                            resulting in version 6.1    */
79
/*                                                                        */
80
/**************************************************************************/
81
1144
UINT  _fxe_unicode_directory_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length,
82
                                    UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name)
83
{
84
85
UINT status, i;
86
87
88
    /* Check for a NULL media or name pointers.  */
89


1144
    if ((media_ptr == FX_NULL) || (old_unicode_name == FX_NULL) || (old_unicode_length == 0) ||
90

733
        (new_unicode_name == FX_NULL) || (new_unicode_length == 0) || (new_short_name == FX_NULL))
91
    {
92
683
        return(FX_PTR_ERROR);
93
    }
94
95
    /* Check for a valid caller.  */
96

461
    FX_CALLER_CHECKING_CODE
97
98
    /* Check unicode zero in old_unicode_name */
99
268
    for (i = 0; i < (old_unicode_length << 1); i += 2)
100
    {
101

216
        if ((old_unicode_name[i] == 0) && (old_unicode_name[i + 1] == 0))
102
        {
103
1
            return(FX_INVALID_NAME);
104
        }
105
    }
106
107
    /* Check unicode zero in new_unicode_name */
108
292
    for (i = 0; i < (new_unicode_length << 1); i += 2)
109
    {
110

241
        if ((new_unicode_name[i] == 0) && (new_unicode_name[i + 1] == 0))
111
        {
112
1
            return(FX_INVALID_NAME);
113
        }
114
    }
115
116
    /* Call actual Unicode directory rename service.  */
117
51
    status =  _fx_unicode_directory_rename(media_ptr, old_unicode_name, old_unicode_length, new_unicode_name, new_unicode_length, new_short_name);
118
119
    /* Return status to the caller.  */
120
51
    return(status);
121
}
122