GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_directory_first_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
/*                                                                        */
40
/*  FUNCTION                                               RELEASE        */
41
/*                                                                        */
42
/*    _fx_directory_first_entry_find                      PORTABLE C      */
43
/*                                                           6.1          */
44
/*  AUTHOR                                                                */
45
/*                                                                        */
46
/*    William E. Lamie, Microsoft Corporation                             */
47
/*                                                                        */
48
/*  DESCRIPTION                                                           */
49
/*                                                                        */
50
/*    This function returns the first directory entry of the current      */
51
/*    working directory.                                                  */
52
/*                                                                        */
53
/*  INPUT                                                                 */
54
/*                                                                        */
55
/*    media_ptr                             Media control block pointer   */
56
/*    directory_name                        Destination for directory     */
57
/*                                            name                        */
58
/*                                                                        */
59
/*  OUTPUT                                                                */
60
/*                                                                        */
61
/*    return status                                                       */
62
/*                                                                        */
63
/*  CALLS                                                                 */
64
/*                                                                        */
65
/*    _fx_directory_next_entry_find         Find next directory entry     */
66
/*                                                                        */
67
/*  CALLED BY                                                             */
68
/*                                                                        */
69
/*    FileX System Functions                                              */
70
/*                                                                        */
71
/**************************************************************************/
72
108
UINT  _fx_directory_first_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name)
73
{
74
75
UINT status;
76
77
78
#ifndef FX_MEDIA_STATISTICS_DISABLE
79
80
    /* Increment the number of times this service has been called.  */
81
108
    media_ptr -> fx_media_directory_first_entry_finds++;
82
#endif
83
84
    /* Check the media to make sure it is open.  */
85
108
    if (media_ptr -> fx_media_id != FX_MEDIA_ID)
86
    {
87
88
        /* Return the media not opened error.  */
89
1
        return(FX_MEDIA_NOT_OPEN);
90
    }
91
92
    /* If trace is enabled, insert this event into the trace buffer.  */
93
    FX_TRACE_IN_LINE_INSERT(FX_TRACE_DIRECTORY_FIRST_ENTRY_FIND, media_ptr, directory_name, 0, 0, FX_TRACE_DIRECTORY_EVENTS, 0, 0)
94
95
    /* Protect against other threads accessing the media.  */
96
107
    FX_PROTECT
97
98
    /* Determine if a local path is in effect at this point.  */
99
#ifndef FX_NO_LOCAL_PATH
100
107
    if (_tx_thread_current_ptr -> tx_thread_filex_ptr)
101
    {
102
103
        /* Yes, there is a local path.  Set the current entry to zero.  */
104
73
        ((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_current_entry =  0;
105
    }
106
    else
107
    {
108
109
        /* Use global default directory.  Set the current entry to 0 in
110
           order to pickup the first entry.  */
111
34
        media_ptr -> fx_media_default_path.fx_path_current_entry =  0;
112
    }
113
#else
114
115
    /* Set the current entry to 0 in order to pickup the first entry.  */
116
    media_ptr -> fx_media_default_path.fx_path_current_entry =  0;
117
#endif
118
119
    /* Release media protection.  */
120
107
    FX_UNPROTECT
121
122
    /* Call the next directory entry to pickup the first entry.  */
123
107
    status =  _fx_directory_next_entry_find(media_ptr, directory_name);
124
125
    /* Return status to the caller.  */
126
107
    return(status);
127
}
128