1FFI::Build::File::Base(U3s)er Contributed Perl DocumentatFiFoIn::Build::File::Base(3)
2
3
4
6 FFI::Build::File::Base - Base class for File::Build files
7
9 version 0.94
10
12 Create your own file class
13
14 package FFI::Build::File::Foo;
15 use base 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
29 This class is the base class for other FFI::Build::File classes.
30
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
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 needs_rebuild
129 my $bool = $file->needs_rebuild
130
131 ld
133 Author: Graham Ollis <plicease@cpan.org>
134
135 Contributors:
136
137 Bakkiaraj Murugesan (bakkiaraj)
138
139 Dylan Cali (calid)
140
141 pipcet
142
143 Zaki Mughal (zmughal)
144
145 Fitz Elliott (felliott)
146
147 Vickenty Fesunov (vyf)
148
149 Gregor Herrmann (gregoa)
150
151 Shlomi Fish (shlomif)
152
153 Damyan Ivanov
154
155 Ilya Pavlov (Ilya33)
156
157 Petr Pisar (ppisar)
158
159 Mohammad S Anwar (MANWAR)
160
162 This software is copyright (c) 2015,2016,2017,2018,2019 by Graham
163 Ollis.
164
165 This is free software; you can redistribute it and/or modify it under
166 the same terms as the Perl 5 programming language system itself.
167
168
169
170perl v5.30.0 2019-07-26 FFI::Build::File::Base(3)