GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fxe_file_extended_relative_seek.c Lines: 9 9 100.0 %
Date: 2026-03-06 18:49:02 Branches: 16 16 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
/**   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
/**************************************************************************/
74
412
UINT  _fxe_file_extended_relative_seek(FX_FILE *file_ptr, ULONG64 byte_offset, UINT seek_from)
75
{
76
77
UINT status;
78
79
80
    /* Check for a null file pointer.  */
81
412
    if (file_ptr == FX_NULL)
82
    {
83
1
        return(FX_PTR_ERROR);
84
    }
85
86
    /* Check for valid seek from option.  */
87

411
    if ((seek_from != FX_SEEK_BEGIN) && (seek_from != FX_SEEK_END) &&
88
2
        (seek_from != FX_SEEK_FORWARD) && (seek_from != FX_SEEK_BACK))
89
    {
90
1
        return(FX_INVALID_OPTION);
91
    }
92
93
    /* Check for a valid caller.  */
94

410
    FX_CALLER_CHECKING_CODE
95
96
    /* Call actual file relative seek service.  */
97
2
    status =  _fx_file_extended_relative_seek(file_ptr, byte_offset, seek_from);
98
99
    /* Seek is complete, return status.  */
100
2
    return(status);
101
}
102