GCC Code Coverage Report


Directory: common/src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 12 / 0 / 12
Functions: 100.0% 1 / 0 / 1
Branches: 100.0% 4 / 0 / 4

fx_directory_first_full_entry_find.c
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 /** 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 /**************************************************************************/
79 109 UINT _fx_directory_first_full_entry_find(FX_MEDIA *media_ptr,
80 CHAR *directory_name, UINT *attributes, ULONG *size,
81 UINT *year, UINT *month, UINT *day, UINT *hour, UINT *minute, UINT *second)
82 {
83
84 UINT status;
85
86
87 #ifndef FX_MEDIA_STATISTICS_DISABLE
88
89 /* Increment the number of times this service has been called. */
90 109 media_ptr -> fx_media_directory_first_full_entry_finds++;
91 #endif
92
93 /* Check the media to make sure it is open. */
94
2/2
✓ Branch 2 → 3 taken 9 times.
✓ Branch 2 → 4 taken 100 times.
109 if (media_ptr -> fx_media_id != FX_MEDIA_ID)
95 {
96
97 /* Return the media not opened error. */
98 9 return(FX_MEDIA_NOT_OPEN);
99 }
100
101 /* If trace is enabled, insert this event into the trace buffer. */
102 FX_TRACE_IN_LINE_INSERT(FX_TRACE_DIRECTORY_FIRST_FULL_ENTRY_FIND, media_ptr, directory_name, 0, 0, FX_TRACE_DIRECTORY_EVENTS, 0, 0)
103
104 /* Protect against other threads accessing the media. */
105 60 FX_PROTECT
106
107 /* Determine if a local path is in effect at this point. */
108 #ifndef FX_NO_LOCAL_PATH
109
2/2
✓ Branch 5 → 6 taken 10 times.
✓ Branch 5 → 7 taken 50 times.
60 if (_tx_thread_current_ptr -> tx_thread_filex_ptr)
110 {
111
112 /* Yes, there is a local path. Set the current entry to zero. */
113 10 ((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_current_entry = 0;
114 }
115 else
116 {
117
118 /* Use global default directory. Set the current entry to 0 in
119 order to pickup the first entry. */
120 50 media_ptr -> fx_media_default_path.fx_path_current_entry = 0;
121 }
122 #else
123
124 /* Set the current entry to 0 in order to pickup the first entry. */
125 40 media_ptr -> fx_media_default_path.fx_path_current_entry = 0;
126 #endif
127
128 /* Release media protection. */
129 60 FX_UNPROTECT
130
131 /* Call the next directory full entry service to pickup the first entry. */
132 100 status = _fx_directory_next_full_entry_find(media_ptr, directory_name, attributes,
133 size, year, month, day, hour, minute, second);
134
135 /* Return status to the caller. */
136 100 return(status);
137 }
138
139