GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_directory_first_full_entry_find.c Lines: 11 11 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_system.h"
30
#include "fx_directory.h"
31
#include "fx_utility.h"
32
33
#ifndef FX_NO_LOCAL_PATH
34
FX_LOCAL_PATH_SETUP
35
#endif
36
37
/**************************************************************************/
38
/*                                                                        */
39
/*  FUNCTION                                               RELEASE        */
40
/*                                                                        */
41
/*    _fx_directory_first_full_entry_find                 PORTABLE C      */
42
/*                                                           6.1          */
43
/*  AUTHOR                                                                */
44
/*                                                                        */
45
/*    William E. Lamie, Microsoft Corporation                             */
46
/*                                                                        */
47
/*  DESCRIPTION                                                           */
48
/*                                                                        */
49
/*    This function returns the first directory entry of the current      */
50
/*    working directory and selected information about the entry.         */
51
/*                                                                        */
52
/*  INPUT                                                                 */
53
/*                                                                        */
54
/*    media_ptr                             Media control block pointer   */
55
/*    directory_name                        Destination for directory     */
56
/*                                            name                        */
57
/*    attributes                            Destination for attributes    */
58
/*    size                                  Destination for size          */
59
/*    year                                  Destination for year          */
60
/*    month                                 Destination for month         */
61
/*    day                                   Destination for day           */
62
/*    hour                                  Destination for hour          */
63
/*    minute                                Destination for minute        */
64
/*    second                                Destination for second        */
65
/*                                                                        */
66
/*  OUTPUT                                                                */
67
/*                                                                        */
68
/*    return status                                                       */
69
/*                                                                        */
70
/*  CALLS                                                                 */
71
/*                                                                        */
72
/*    _fx_directory_next_full_entry_find    Find next full directory entry*/
73
/*                                                                        */
74
/*  CALLED BY                                                             */
75
/*                                                                        */
76
/*    FileX System Functions                                              */
77
/*                                                                        */
78
/*  RELEASE HISTORY                                                       */
79
/*                                                                        */
80
/*    DATE              NAME                      DESCRIPTION             */
81
/*                                                                        */
82
/*  05-19-2020     William E. Lamie         Initial Version 6.0           */
83
/*  09-30-2020     William E. Lamie         Modified comment(s),          */
84
/*                                            resulting in version 6.1    */
85
/*                                                                        */
86
/**************************************************************************/
87
13
UINT  _fx_directory_first_full_entry_find(FX_MEDIA *media_ptr,
88
                                          CHAR *directory_name, UINT *attributes, ULONG *size,
89
                                          UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second)
90
{
91
92
UINT status;
93
94
95
#ifndef FX_MEDIA_STATISTICS_DISABLE
96
97
    /* Increment the number of times this service has been called.  */
98
13
    media_ptr -> fx_media_directory_first_full_entry_finds++;
99
#endif
100
101
    /* Check the media to make sure it is open.  */
102
13
    if (media_ptr -> fx_media_id != FX_MEDIA_ID)
103
    {
104
105
        /* Return the media not opened error.  */
106
1
        return(FX_MEDIA_NOT_OPEN);
107
    }
108
109
    /* If trace is enabled, insert this event into the trace buffer.  */
110
    FX_TRACE_IN_LINE_INSERT(FX_TRACE_DIRECTORY_FIRST_FULL_ENTRY_FIND, media_ptr, directory_name, 0, 0, FX_TRACE_DIRECTORY_EVENTS, 0, 0)
111
112
    /* Protect against other threads accessing the media.  */
113
12
    FX_PROTECT
114
115
    /* Determine if a local path is in effect at this point.  */
116
#ifndef FX_NO_LOCAL_PATH
117
12
    if (_tx_thread_current_ptr -> tx_thread_filex_ptr)
118
    {
119
120
        /* Yes, there is a local path.  Set the current entry to zero.  */
121
2
        ((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_current_entry =  0;
122
    }
123
    else
124
    {
125
126
        /* Use global default directory.  Set the current entry to 0 in
127
           order to pickup the first entry.  */
128
10
        media_ptr -> fx_media_default_path.fx_path_current_entry =  0;
129
    }
130
#else
131
132
    /* Set the current entry to 0 in order to pickup the first entry.  */
133
    media_ptr -> fx_media_default_path.fx_path_current_entry =  0;
134
#endif
135
136
    /* Release media protection.  */
137
12
    FX_UNPROTECT
138
139
    /* Call the next directory full entry service to pickup the first entry.  */
140
12
    status =  _fx_directory_next_full_entry_find(media_ptr, directory_name, attributes,
141
                                                 size, year, month, day, hour, minute, second);
142
143
    /* Return status to the caller.  */
144
12
    return(status);
145
}
146