GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_directory_default_get_copy.c Lines: 8 8 100.0 %
Date: 2024-01-10 21:53:23 Branches: 4 4 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
/**   Directory                                                           */
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_directory.h"
30
#include "fx_utility.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _fx_directory_default_get_copy                      PORTABLE C      */
37
/*                                                           6.1.6        */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    William E. Lamie, Microsoft Corporation                             */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function copies the last path provided to the                  */
45
/*    fx_directory_default_set function into the specified buffer.        */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    media_ptr                             Media control block pointer   */
50
/*    return_path_name_buffer               Destination buffer for name   */
51
/*    return_path_name_buffer_size          Size of buffer pointed to by  */
52
/*                                            return_path_name_buffer     */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    return status                                                       */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    None                                                                */
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), verified */
72
/*                                            memcpy usage,               */
73
/*                                            resulting in version 6.1    */
74
/*  04-02-2021     William E. Lamie         Modified comment(s), verified */
75
/*                                            memcpy usage,               */
76
/*                                            resulting in version 6.1.6  */
77
/*                                                                        */
78
/**************************************************************************/
79
3
UINT  _fx_directory_default_get_copy(FX_MEDIA *media_ptr, CHAR *return_path_name_buffer, UINT return_path_name_buffer_size)
80
{
81
82
UINT    status;
83
CHAR    *return_path_name;
84
UINT    path_name_length_with_null_terminator;
85
86
87
    /* Get the pointer to the path.  */
88
3
    status =  _fx_directory_default_get(media_ptr, &return_path_name);
89
3
    if (status == FX_SUCCESS)
90
    {
91
92
        /* Get the length of the path.  */
93
2
        path_name_length_with_null_terminator =  _fx_utility_string_length_get(return_path_name, FX_MAXIMUM_PATH) + 1;
94
95
        /* Can it fit in the user's buffer? */
96
2
        if (path_name_length_with_null_terminator <= return_path_name_buffer_size)
97
        {
98
99
            /* Copy the path name into the user's buffer.  */
100
1
            _fx_utility_memory_copy((UCHAR *) return_path_name, (UCHAR *) return_path_name_buffer, path_name_length_with_null_terminator); /* Use case of memcpy is verified. */
101
        }
102
        else
103
        {
104
105
            /* Buffer is too small. Return error.  */
106
1
            return(FX_BUFFER_ERROR);
107
        }
108
109
    }
110
111
    /* Return successful status.  */
112
2
    return(status);
113
}
114