GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fxe_unicode_file_rename.c Lines: 13 13 100.0 %
Date: 2026-03-06 18:49:02 Branches: 30 30 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
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_file_create                            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 file rename service. */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    media_ptr                             Pointer to media              */
52
/*    old_unicode_name                      Pointer to old unicode name   */
53
/*    old_unicode_length                    Old unicode name length       */
54
/*    new_unicode_name                      Pointer to new unicode name   */
55
/*    new_unicode_length                    New unicode name length       */
56
/*    new_short_name                        Designated new short name     */
57
/*                                                                        */
58
/*  OUTPUT                                                                */
59
/*                                                                        */
60
/*    Completion Status                                                   */
61
/*                                                                        */
62
/*  CALLS                                                                 */
63
/*                                                                        */
64
/*    _fx_unicode_file_rename               Actual Unicode file rename    */
65
/*                                            service                     */
66
/*                                                                        */
67
/*  CALLED BY                                                             */
68
/*                                                                        */
69
/*    Application Code                                                    */
70
/*                                                                        */
71
/**************************************************************************/
72
1137
UINT _fxe_unicode_file_rename(FX_MEDIA *media_ptr, UCHAR *old_unicode_name, ULONG old_unicode_length,
73
                              UCHAR *new_unicode_name, ULONG new_unicode_length, CHAR *new_short_name)
74
{
75
76
UINT status, i;
77
78
79
    /* Check for a NULL media or name pointers.  */
80


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

726
        (new_unicode_name == FX_NULL) || (new_unicode_length == 0) || (new_short_name == FX_NULL))
82
    {
83
683
        return(FX_PTR_ERROR);
84
    }
85
86
    /* Check for a valid caller.  */
87

454
    FX_CALLER_CHECKING_CODE
88
89
    /* Check unicode zero in old_unicode_name */
90
229
    for (i = 0; i < (old_unicode_length << 1); i += 2)
91
    {
92

184
        if ((old_unicode_name[i] == 0) && (old_unicode_name[i + 1] == 0))
93
        {
94
1
            return(FX_INVALID_NAME);
95
        }
96
    }
97
98
    /* Check unicode zero in new_unicode_name */
99
253
    for (i = 0; i < (new_unicode_length << 1); i += 2)
100
    {
101

209
        if ((new_unicode_name[i] == 0) && (new_unicode_name[i + 1] == 0))
102
        {
103
1
            return(FX_INVALID_NAME);
104
        }
105
    }
106
107
    /* Call actual Unicode file rename service.  */
108
44
    status =  _fx_unicode_file_rename(media_ptr, old_unicode_name, old_unicode_length,
109
                                      new_unicode_name, new_unicode_length, new_short_name);
110
111
    /* Return status to the caller.  */
112
44
    return(status);
113
}
114