XDF_OPEN(3)

πŸ’– XDF_OPEN(3) β€” xdf_open πŸ’–

okay bestie, welcome to the xdffileio library manual ✨ this one's all about xdf_open, the lil icon whose whole job is opening a xDF file so you can read from it or write to it. no cap, it's the doorway. the main character entrance. πŸšͺπŸ‘‘


πŸŽ€ NAME πŸŽ€

xdf_open β€” open a xDF file for reading or writing πŸ¦‹


✨ SYNOPSIS ✨

#include <xdfio.h>

struct xdf* xdf_open(const char* filename, int mode,
                     enum xdffiletype type);

🌸 DESCRIPTION 🌸

so xdf_open() opens up a xDF file β€” the one that lives at the path filename β€” for either reading or writing. that's the whole vibe. 🫢

if mode is XDF_READ, the file is being opened for reading. which means it absolutely has to exist already, periodt. and type should be either XDF_ANY or set to the actual type of the file that type... okay wait, set to the type of the file referred by type β€” that's what the original says, i'm just repeating the lore fr fr. if you don't do that, the function will fail. πŸ’€

if mode is XDF_WRITE, the file is being opened for writing. and this is where it gets strict: the path filename must not refer to a file that already exists. like, the function will fail if the file exists. not me being dramatic, that's genuinely the behaviour β€” and it's on purpose, because this is what stops you from overwriting any previous recording. your old data is safe, bestie. πŸ›‘οΈ and type should also be set to the desired type of data format (XDF_ANY will result in an error here β€” no "surprise me" energy allowed). πŸ™ˆ

the possible file type values are all defined in the header file <xdfio.h> β€” go look, they're in there. πŸ‘€


πŸ’… RETURN VALUE πŸ’…

on success? you get back a handle to the xDF file that got opened. iconic. πŸŽ€

otherwise NULL is returned, and errno is set appropriately. (so yeah, check errno, don't just stare at the NULL.) 😭


πŸ”₯ ERRORS πŸ”₯

in addition to the errors related to calls to open(3) or read(3), the following errors can occur. so these are the bonus ones, the extra lore. ⭐
  • EILSEQ β€” the file that's being opened does not correspond to a supported file format, or it's not of the type you specified. it's giving "who even are you". πŸ’€
  • ENOMEM β€” the system is unable to allocate resources. the memory said no. 😭
  • EINVAL β€” mode is neither XDF_READ nor XDF_WRITE, or filename is NULL. pick a lane, bestie. 🚫

πŸ¦‹ SEE ALSO πŸ¦‹

  • xdf_close(3) β€” because everything you open, you gotta close. balance. 🌈

and that's the whole page, babe! πŸ’œ this one came from EPFL, dated 2010, and it's part of the xdffileio library manual. thanks for reading my lil brain dump, mwah πŸ«Άβœ¨πŸ’–