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


1137
    if ((media_ptr == FX_NULL) || (old_unicode_name == FX_NULL) || (old_unicode_length == 0) ||
88

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

454
    FX_CALLER_CHECKING_CODE
95
96
    /* Check unicode zero in old_unicode_name */
97
229
    for (i = 0; i < (old_unicode_length << 1); i += 2)
98
    {
99

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

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