GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_directory_first_full_entry_find.c Lines: 11 11 100.0 %
Date: 2026-03-06 18:49:02 Branches: 4 4 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
/**   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
13
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
13
    media_ptr -> fx_media_directory_first_full_entry_finds++;
91
#endif
92
93
    /* Check the media to make sure it is open.  */
94
13
    if (media_ptr -> fx_media_id != FX_MEDIA_ID)
95
    {
96
97
        /* Return the media not opened error.  */
98
1
        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
12
    FX_PROTECT
106
107
    /* Determine if a local path is in effect at this point.  */
108
#ifndef FX_NO_LOCAL_PATH
109
12
    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
2
        ((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
10
        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
    media_ptr -> fx_media_default_path.fx_path_current_entry =  0;
126
#endif
127
128
    /* Release media protection.  */
129
12
    FX_UNPROTECT
130
131
    /* Call the next directory full entry service to pickup the first entry.  */
132
12
    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
12
    return(status);
137
}
138