fxe_file_extended_relative_seek.c
| 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 | 2102 | 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 |
2/2✓ Branch 2 → 3 taken 8 times.
✓ Branch 2 → 4 taken 2094 times.
|
2102 | if (file_ptr == FX_NULL) |
| 82 | { | ||
| 83 | 8 | return(FX_PTR_ERROR); | |
| 84 | } | ||
| 85 | |||
| 86 | /* Check for valid seek from option. */ | ||
| 87 |
6/6✓ Branch 4 → 5 taken 1396 times.
✓ Branch 4 → 9 taken 698 times.
✓ Branch 5 → 6 taken 706 times.
✓ Branch 5 → 9 taken 690 times.
✓ Branch 6 → 7 taken 16 times.
✓ Branch 6 → 9 taken 690 times.
|
2094 | if ((seek_from != FX_SEEK_BEGIN) && (seek_from != FX_SEEK_END) && |
| 88 |
2/2✓ Branch 7 → 8 taken 8 times.
✓ Branch 7 → 9 taken 8 times.
|
16 | (seek_from != FX_SEEK_FORWARD) && (seek_from != FX_SEEK_BACK)) |
| 89 | { | ||
| 90 | 8 | return(FX_INVALID_OPTION); | |
| 91 | } | ||
| 92 | |||
| 93 | /* Check for a valid caller. */ | ||
| 94 |
6/6✓ Branch 9 → 10 taken 1388 times.
✓ Branch 9 → 12 taken 690 times.
✓ Branch 10 → 11 taken 698 times.
✓ Branch 10 → 12 taken 690 times.
✓ Branch 11 → 12 taken 690 times.
✓ Branch 11 → 13 taken 8 times.
|
2078 | FX_CALLER_CHECKING_CODE |
| 95 | |||
| 96 | /* Call actual file relative seek service. */ | ||
| 97 | 16 | status = _fx_file_extended_relative_seek(file_ptr, byte_offset, seek_from); | |
| 98 | |||
| 99 | /* Seek is complete, return status. */ | ||
| 100 | 16 | return(status); | |
| 101 | } | ||
| 102 | |||
| 103 |