FFI::C...sixFile(3pm)

πŸ’– FFI::C::PosixFile πŸ’–

okay bestie, welcome to the FFI::C::PosixFile manual page (perl v5.36.0, section 3pm, from the User Contributed Perl Documentation) β€” it's giving very niche, very powerful, and honestly? kinda iconic. πŸŽ€


✨ NAME ✨

FFI::C::PosixFile β€” Perl interface to C File pointer with POSIX extensions πŸ¦‹


🌸 VERSION 🌸

version 0.15 β€” yes, she's got a number and she's proud of it πŸ’…


🌈 SYNOPSIS 🌈

here's the vibe, literally copy-paste-able:

use FFI::C::PosixFile;

my $stdout = FFI::C::PosixFile->fdopen(1, "w");
say $stdout->fileno;  # prints 1

look at her go 🫢 that 1 is stdout's file descriptor and no I will not be taking questions.


πŸ’œ DESCRIPTION πŸ’œ

so this is a subclass of FFI::C::File, right? and what it does is add a couple of genuinely useful POSIX extensions on top β€” the kind of stuff that might not be available on non-POSIX systems. 🐚

heads up bestie: if you try to create an instance of this class on a platform that doesn't support those extensions, it will fail. no cap. she is POSIX-only and she knows it. 😭

🧚 CONSTRUCTOR 🧚

fopen

my $file = FFI::C::PosixFile->fopen($filename, $mode);

opens the file with the given mode. as for the exact format of $mode? that's a you-and-your-standard-library-C-documentation situation, go check the C docs. ✨

new

my $file = FFI::C::PosixFile->new($ptr);

creates a shiny new File instance object from the opaque pointer. πŸ‘‘

⚠️ real talk: it is not possible to do any error checking on the type here. so please, please make sure the pointer you're handing over really is a C file pointer. that's on you, bestie. πŸ™ˆ

fdopen

my $file = FFI::C::PosixFile->fdopen($fd, $mode);

creates a new File instance straight from a POSIX file descriptor. that's the whole thing, she's simple like that. πŸ“


πŸ‘‘ METHODS πŸ‘‘

fileno

my $fd = $file->fileno;

returns the POSIX file descriptor for the file pointer. that's it. that's the method. short queen behavior. πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

the whole friend group, go say hi:

  • FFI::C
  • FFI::C::Array
  • FFI::C::ArrayDef
  • FFI::C::Def
  • FFI::C::File
  • FFI::C::PosixFile
  • FFI::C::Struct
  • FFI::C::StructDef
  • FFI::C::Union
  • FFI::C::UnionDef
  • FFI::C::Util
  • FFI::Platypus::Record

πŸŽ€ AUTHOR πŸŽ€

Graham Ollis <plicease@cpan.org> β€” legend behavior fr fr 🌟


this software is copyright (c) 2020-2022 by Graham Ollis.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. πŸ’–


and that's the whole page bestie!! 🌈 perl v5.36.0, dated 2023-02-06, straight from the User Contributed Perl Documentation β€” tysm for reading, mwah πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from