1FFI::Build::File::Base(U3s)er Contributed Perl DocumentatFiFoIn::Build::File::Base(3)
2
3
4

NAME

6       FFI::Build::File::Base - Base class for File::Build files
7

VERSION

9       version 2.05
10

SYNOPSIS

12       Create your own file class
13
14        package FFI::Build::File::Foo;
15        use parent qw( FFI::Build::File::Base );
16        use constant default_suffix => '.foo';
17        use constant default_encoding => ':utf8';
18
19       Use it:
20
21        # use an existing file in the filesystem
22        my $file = FFI::Build::File::Foo->new('src/myfile.foo');
23
24        # generate a temp file with provided content
25        # file will be deletd when $file falls out of scope.
26        my $file = FFI::Build::File::Foo->new(\'content for a temp foo');
27

DESCRIPTION

29       This class is the base class for other "FFI::Build::File::*" classes.
30

CONSTRUCTOR

32   new
33        my $file = FFI::Build::File::Base->new(\$content, %options);
34        my $file = FFI::Build::File::Base->new($filename, %options);
35
36       Create a new instance of the file class.  You may provide either the
37       content of the file as a scalar reference, or the path to an existing
38       filename.  Options:
39
40       base
41           The base name for any temporary file "ffi_build_" by default.
42
43       build
44           The FFI::Build instance to use.
45
46       dir The directory to store any temporary file.
47
48       platform
49           The FFI::Build::Platform instance to use.
50

METHODS

52   default_suffix
53        my $suffix = $file->default_suffix;
54
55       MUST be overridden in the subclass.  This is the standard extension for
56       the file type.  ".c" for a C file, ".o" or ".obj" for an object file
57       depending on platform.  etc.
58
59   default_encoding
60        my $encoding = $file->default_encoding;
61
62       MUST be overridden in the subclass.  This is the passed to "binmode"
63       when the file is opened for reading or writing.
64
65   accept_suffix
66        my @suffix_list = $file->accept_suffix;
67
68       Returns a list of regexes that recognize the file type.
69
70   path
71        my $path = $file->path;
72
73       The full or relative path to the file.
74
75   basename
76        my $basename = $file->basename;
77
78       The base filename part of the path.
79
80   dirname
81        my $dir = $file->dirname;
82
83       The directory part of the path.
84
85   is_temp
86        my $bool = $file->is_temp;
87
88       Returns true if the file is temporary, that is, it will be deleted when
89       the file object falls out of scope.  You can call "keep", to keep the
90       file.
91
92   platform
93        my $platform = $file->platform;
94
95       The FFI::Build::Platform instance used for this file object.
96
97   build
98        my $build = $file->build;
99
100       The FFI::Build instance used for this file object, if any.
101
102   native
103        my $path = $file->native;
104
105       Returns the operating system native version of the filename path.  On
106       Windows, this means that forward slash "\" is used instead of backslash
107       "/".
108
109   slurp
110        my $content = $file->slurp;
111
112       Returns the content of the file.
113
114   keep
115        $file->keep;
116
117       Turns off the temporary flag on the file object, meaning it will not
118       automatically be deleted when the file object is deallocated or falls
119       out of scope.
120
121   build_item
122        $file->build_item;
123
124       Builds the file into its natural output type, usually an object file.
125       It returns a new file instance, or if the file is an object file then
126       it returns empty list.
127
128   build_all
129        $file->build_all;
130
131       If implemented the file in question can directly create a shared or
132       dynamic library without needing a link step.  This is useful for
133       languages that have their own build systems.
134
135   needs_rebuild
136        my $bool = $file->needs_rebuild
137
138   ld

AUTHOR

140       Author: Graham Ollis <plicease@cpan.org>
141
142       Contributors:
143
144       Bakkiaraj Murugesan (bakkiaraj)
145
146       Dylan Cali (calid)
147
148       pipcet
149
150       Zaki Mughal (zmughal)
151
152       Fitz Elliott (felliott)
153
154       Vickenty Fesunov (vyf)
155
156       Gregor Herrmann (gregoa)
157
158       Shlomi Fish (shlomif)
159
160       Damyan Ivanov
161
162       Ilya Pavlov (Ilya33)
163
164       Petr Písař (ppisar)
165
166       Mohammad S Anwar (MANWAR)
167
168       Håkon Hægland (hakonhagland, HAKONH)
169
170       Meredith (merrilymeredith, MHOWARD)
171
172       Diab Jerius (DJERIUS)
173
174       Eric Brine (IKEGAMI)
175
176       szTheory
177
178       José Joaquín Atria (JJATRIA)
179
180       Pete Houston (openstrike, HOUSTON)
181
183       This software is copyright (c) 2015-2022 by Graham Ollis.
184
185       This is free software; you can redistribute it and/or modify it under
186       the same terms as the Perl 5 programming language system itself.
187
188
189
190perl v5.36.0                      2022-11-18         FFI::Build::File::Base(3)
Impressum