FGETPOS(3POSIX)

πŸ’– FGETPOS(3POSIX) πŸ’–

okay bestie, so this little gem lives in the POSIX Programmer's Manual (yes, the 3POSIX one, we're fancy here) ✨


🌸 PROLOG 🌸

okay so before we even get into it, heads up: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β€” so like, go consult the corresponding Linux manual page for the deets on Linux behavior β€” or honestly, the interface may not even be implemented on Linux at all. vibe check first, always 🫢


πŸ‘‘ NAME πŸ‘‘

fgetpos β€” get current file position information πŸ’…


✨ SYNOPSIS ✨

#include <stdio.h>

int fgetpos(FILE *restrict stream, fpos_t *restrict pos);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, the functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional, no cap. This volume of POSIX.1-2017 defers to the ISO C standard. periodt. πŸ“œ

The fgetpos() function shall store the current values of the parse state (if any) and file position indicator for the stream pointed to by stream in the object pointed to by pos. The value stored contains unspecified information usable by fsetpos() for repositioning the stream to its position at the time of the call to fgetpos(). it's giving bookmark energy, fr fr πŸ”–

The fgetpos() function shall not change the setting of errno if successful. so if it ate, it leaves errno completely alone. iconic behavior honestly πŸ’€


πŸŽ€ RETURN VALUE πŸŽ€

Upon successful completion, fgetpos() shall return 0 β€” slay. Otherwise, it shall return a non-zero value and set errno to indicate the error. not slay. 😭


πŸ”₯ ERRORS πŸ”₯

The fgetpos() function shall fail if:

  • EBADF β€” The file descriptor underlying stream is not valid. bestie that stream is not real, i'm so sorry πŸ’€
  • EOVERFLOW β€” The current value of the file position cannot be represented correctly in an object of type fpos_t. it literally does not fit, the number is too big for the little box πŸ™ˆ
  • ESPIPE β€” The file descriptor underlying stream is associated with a pipe, FIFO, or socket. you cannot seek a pipe, that's not a thing, stop trying 🚫
ngl the following sections are informative, so they're the bonus content, not the main quest ✨

🌈 EXAMPLES 🌈

None. (nothing here, bestie, the examples section is empty, we move) πŸ™ˆ


πŸ“ APPLICATION USAGE πŸ“

None. (also empty! two for two πŸŽ€)


πŸ’œ RATIONALE πŸ’œ

None. (empty again, this page is lowkey a minimalist queen πŸ‘‘)


⭐ FUTURE DIRECTIONS ⭐

None. (yep. empty. the void. πŸ’€)


🧚 SEE ALSO 🧚

  • Section 2.5, Standard I/O Streams
  • fopen()
  • ftell()
  • rewind()
  • ungetc()
  • The Base Definitions volume of POSIX.1-2017, <stdio.h>

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document β€” like, they're the main character, this page is just the group chat recap. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


okay and that's the whole thing!! πŸŒΈπŸ’–βœ¨ this absolute baddie of a page is brought to you by IEEE/The Open Group, 2017, and the manual page is FGETPOS(3POSIX) β€” go forth and get those file positions, bestie, i'm obsessed with you πŸ«ΆπŸ‘‘πŸ’