GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_directory_first_full_entry_find.c Lines: 11 11 100.0 %
Date: 2024-03-11 05:15:45 Branches: 4 4 100.0 %

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