GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fxe_file_extended_relative_seek.c Lines: 9 9 100.0 %
Date: 2024-01-10 21:53:23 Branches: 16 16 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
/**   File                                                                */
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_file.h"
30
31
FX_CALLER_CHECKING_EXTERNS
32
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _fxe_file_extended_relative_seek                    PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    William E. Lamie, Microsoft Corporation                             */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function checks for errors in the file relative seek call.     */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    file_ptr                              File control block pointer    */
51
/*    byte_offset                           Byte offset of the seek       */
52
/*    seek_from                             Direction for relative seek,  */
53
/*                                          legal values are:             */
54
/*                                                                        */
55
/*                                              FX_SEEK_BEGIN             */
56
/*                                              FX_SEEK_END               */
57
/*                                              FX_SEEK_FORWARD           */
58
/*                                              FX_SEEK_BACK              */
59
/*                                                                        */
60
/*  OUTPUT                                                                */
61
/*                                                                        */
62
/*    return status                                                       */
63
/*                                                                        */
64
/*  CALLS                                                                 */
65
/*                                                                        */
66
/*    _fx_file_extended_relative_seek       Actual relative file seek     */
67
/*                                            service                     */
68
/*                                                                        */
69
/*  CALLED BY                                                             */
70
/*                                                                        */
71
/*    Application Code                                                    */
72
/*                                                                        */
73
/*  RELEASE HISTORY                                                       */
74
/*                                                                        */
75
/*    DATE              NAME                      DESCRIPTION             */
76
/*                                                                        */
77
/*  05-19-2020     William E. Lamie         Initial Version 6.0           */
78
/*  09-30-2020     William E. Lamie         Modified comment(s),          */
79
/*                                            resulting in version 6.1    */
80
/*                                                                        */
81
/**************************************************************************/
82
412
UINT  _fxe_file_extended_relative_seek(FX_FILE *file_ptr, ULONG64 byte_offset, UINT seek_from)
83
{
84
85
UINT status;
86
87
88
    /* Check for a null file pointer.  */
89
412
    if (file_ptr == FX_NULL)
90
    {
91
1
        return(FX_PTR_ERROR);
92
    }
93
94
    /* Check for valid seek from option.  */
95

411
    if ((seek_from != FX_SEEK_BEGIN) && (seek_from != FX_SEEK_END) &&
96
2
        (seek_from != FX_SEEK_FORWARD) && (seek_from != FX_SEEK_BACK))
97
    {
98
1
        return(FX_INVALID_OPTION);
99
    }
100
101
    /* Check for a valid caller.  */
102

410
    FX_CALLER_CHECKING_CODE
103
104
    /* Call actual file relative seek service.  */
105
2
    status =  _fx_file_extended_relative_seek(file_ptr, byte_offset, seek_from);
106
107
    /* Seek is complete, return status.  */
108
2
    return(status);
109
}
110