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::CFFI::C::ArrayFFI::C::ArrayDefFFI::C::DefFFI::C::FileFFI::C::PosixFileFFI::C::StructFFI::C::StructDefFFI::C::UnionFFI::C::UnionDefFFI::C::UtilFFI::Platypus::Record
π AUTHOR π
Graham Ollis <plicease@cpan.org> β legend behavior fr fr π
β COPYRIGHT AND LICENSE β
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
- debian bookworm: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libffi-c-perl 0.15-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms