FGETPOS(3P)

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

okay so this one lives in the POSIX Programmer's Manual, bestie, and it's the whole fgetpos situation. quick heads up before we dive in πŸ‘‡

🌸 PROLOG 🌸

so like, this manual page is part of the POSIX Programmer's Manual. that's the vibe. but β€” and this is important β€” the Linux implementation of this interface may differ, so if you're on Linux, go consult the corresponding Linux manual page for the deets on Linux behavior. or honestly, the interface might not even be implemented on Linux at all. no cap. 🫢


✨ NAME ✨

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


🌈 SYNOPSIS 🌈

#include <stdio.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first things first: everything described on this reference page is aligned with the ISO C standard. if there's any conflict between what's written here and the ISO C standard, that conflict is unintentional β€” not on purpose, not a vibe. this volume of POSIX.1‐2017 defers to the ISO C standard. periodt. πŸ‘‘

so what does fgetpos() actually do? it shall store the current values of the parse state (if any) and the file position indicator for the stream pointed to by stream into the object pointed to by pos. iconic.

and the value it stores? it contains unspecified information β€” usable by fsetpos() for repositioning the stream back to its position at the time of the call to fgetpos(). so like, it's a lil bookmark πŸŽ€ you hand back to fsetpos() later. you don't need to know what's inside it, iykyk.

also very important bestie: the fgetpos() function shall not change the setting of errno if successful. not touching it. leaving errno exactly how it found it. respectful. πŸ™ˆ


πŸ’œ RETURN VALUE πŸ’œ

  • upon successful completion, fgetpos() shall return 0 πŸŽ‰
  • otherwise, it shall return a non-zero value and set errno to indicate the error 😭

πŸ”₯ ERRORS πŸ”₯

the fgetpos() function shall fail if:

  • EBADF β€” the file descriptor underlying stream is not valid. πŸ’€
  • EOVERFLOW β€” the current value of the file position cannot be represented correctly in an object of type fpos_t. like it literally doesn't fit, sorry bestie 😭
  • ESPIPE β€” the file descriptor underlying stream is associated with a pipe, FIFO, or socket. pipes don't do positions, that's just the rules. 🚫
heads up: the following sections are informative. they're the vibes, not the requirements. ✨

πŸŽ€ EXAMPLES πŸŽ€

None. (yes really, nothing here, we move πŸƒβ€β™€οΈ)


🌸 APPLICATION USAGE 🌸

None. (also nothing, iconic of them honestly)


⭐ RATIONALE ⭐

None. (empty, but make it fashion)


🌈 FUTURE DIRECTIONS 🌈

None. (the future is a mystery, but not here specifically)


πŸ‘‘ SEE ALSO πŸ‘‘

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

okay so legally I have to say this and I'm gonna say it with love:

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. 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 .


and that's the whole page bestie!! mwah πŸ’‹ this one came from IEEE/The Open Group, dated 2017 β€” thanks for reading, ily, go call fgetpos() responsibly 🫢✨

πŸ“¦ where this page comes from