GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_directory_first_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
/*                                                                        */
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
/*  RELEASE HISTORY                                                       */
72
/*                                                                        */
73
/*    DATE              NAME                      DESCRIPTION             */
74
/*                                                                        */
75
/*  05-19-2020     William E. Lamie         Initial Version 6.0           */
76
/*  09-30-2020     William E. Lamie         Modified comment(s),          */
77
/*                                            resulting in version 6.1    */
78
/*                                                                        */
79
/**************************************************************************/
80
108
UINT  _fx_directory_first_entry_find(FX_MEDIA *media_ptr, CHAR *directory_name)
81
{
82
83
UINT status;
84
85
86
#ifndef FX_MEDIA_STATISTICS_DISABLE
87
88
    /* Increment the number of times this service has been called.  */
89
108
    media_ptr -> fx_media_directory_first_entry_finds++;
90
#endif
91
92
    /* Check the media to make sure it is open.  */
93
108
    if (media_ptr -> fx_media_id != FX_MEDIA_ID)
94
    {
95
96
        /* Return the media not opened error.  */
97
1
        return(FX_MEDIA_NOT_OPEN);
98
    }
99
100
    /* If trace is enabled, insert this event into the trace buffer.  */
101
    FX_TRACE_IN_LINE_INSERT(FX_TRACE_DIRECTORY_FIRST_ENTRY_FIND, media_ptr, directory_name, 0, 0, FX_TRACE_DIRECTORY_EVENTS, 0, 0)
102
103
    /* Protect against other threads accessing the media.  */
104
107
    FX_PROTECT
105
106
    /* Determine if a local path is in effect at this point.  */
107
#ifndef FX_NO_LOCAL_PATH
108
107
    if (_tx_thread_current_ptr -> tx_thread_filex_ptr)
109
    {
110
111
        /* Yes, there is a local path.  Set the current entry to zero.  */
112
73
        ((FX_PATH *)_tx_thread_current_ptr -> tx_thread_filex_ptr) -> fx_path_current_entry =  0;
113
    }
114
    else
115
    {
116
117
        /* Use global default directory.  Set the current entry to 0 in
118
           order to pickup the first entry.  */
119
34
        media_ptr -> fx_media_default_path.fx_path_current_entry =  0;
120
    }
121
#else
122
123
    /* Set the current entry to 0 in order to pickup the first entry.  */
124
    media_ptr -> fx_media_default_path.fx_path_current_entry =  0;
125
#endif
126
127
    /* Release media protection.  */
128
107
    FX_UNPROTECT
129
130
    /* Call the next directory entry to pickup the first entry.  */
131
107
    status =  _fx_directory_next_entry_find(media_ptr, directory_name);
132
133
    /* Return status to the caller.  */
134
107
    return(status);
135
}
136