| 1 |
package FFI::Platypus::ShareConfig; |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use 5.008004; |
| 6 |
use File::Spec; |
| 7 |
|
| 8 |
our $VERSION = '2.12'; # VERSION |
| 9 |
|
| 10 |
sub dist_dir ($) |
| 11 |
{ |
| 12 |
my($dist_name) = @_; |
| 13 |
|
| 14 |
my @pm = split /-/, $dist_name; |
| 15 |
$pm[-1] .= ".pm"; |
| 16 |
|
| 17 |
foreach my $inc (@INC) |
| 18 |
{ |
| 19 |
if(-f File::Spec->catfile($inc, @pm)) |
| 20 |
{ |
| 21 |
my $share = File::Spec->catdir($inc, qw( auto share dist ), $dist_name ); |
| 22 |
if(-d $share) |
| 23 |
{ |
| 24 |
return File::Spec->rel2abs($share); |
| 25 |
} |
| 26 |
last; |
| 27 |
} |
| 28 |
} |
| 29 |
Carp::croak("unable to find dist share directory for $dist_name"); |
| 30 |
} |
| 31 |
|
| 32 |
sub get |
| 33 |
{ |
| 34 |
my(undef, $name) = @_; |
| 35 |
my $config; |
| 36 |
|
| 37 |
unless($config) |
| 38 |
{ |
| 39 |
my $fn = File::Spec->catfile(dist_dir('FFI-Platypus'), 'config.pl'); |
| 40 |
$fn = File::Spec->rel2abs($fn) unless File::Spec->file_name_is_absolute($fn); |
| 41 |
local $@; |
| 42 |
unless($config = do $fn) |
| 43 |
{ |
| 44 |
die "couldn't parse configuration $fn $@" if $@; |
| 45 |
die "couldn't do $fn $!" if $!; |
| 46 |
die "bad or missing config file $fn"; |
| 47 |
}; |
| 48 |
} |
| 49 |
|
| 50 |
defined $name ? $config->{$name} : $config; |
| 51 |
} |
| 52 |
|
| 53 |
1; |
| 54 |
|
| 55 |
__END__ |
| 56 |
|
| 57 |
=pod |
| 58 |
|
| 59 |
=encoding UTF-8 |
| 60 |
|
| 61 |
=head1 NAME |
| 62 |
|
| 63 |
FFI::Platypus::ShareConfig |
| 64 |
|
| 65 |
=head1 VERSION |
| 66 |
|
| 67 |
version 2.12 |
| 68 |
|
| 69 |
=head1 AUTHOR |
| 70 |
|
| 71 |
Author: Graham Ollis E<lt>[email protected]<gt> |
| 72 |
|
| 73 |
Contributors: |
| 74 |
|
| 75 |
Bakkiaraj Murugesan (bakkiaraj) |
| 76 |
|
| 77 |
Dylan Cali (calid) |
| 78 |
|
| 79 |
pipcet |
| 80 |
|
| 81 |
Zaki Mughal (zmughal) |
| 82 |
|
| 83 |
Fitz Elliott (felliott) |
| 84 |
|
| 85 |
Vickenty Fesunov (vyf) |
| 86 |
|
| 87 |
Gregor Herrmann (gregoa) |
| 88 |
|
| 89 |
Shlomi Fish (shlomif) |
| 90 |
|
| 91 |
Damyan Ivanov |
| 92 |
|
| 93 |
Ilya Pavlov (Ilya33) |
| 94 |
|
| 95 |
Petr Písař (ppisar) |
| 96 |
|
| 97 |
Mohammad S Anwar (MANWAR) |
| 98 |
|
| 99 |
Håkon Hægland (hakonhagland, HAKONH) |
| 100 |
|
| 101 |
Meredith (merrilymeredith, MHOWARD) |
| 102 |
|
| 103 |
Diab Jerius (DJERIUS) |
| 104 |
|
| 105 |
Eric Brine (IKEGAMI) |
| 106 |
|
| 107 |
szTheory |
| 108 |
|
| 109 |
José Joaquín Atria (JJATRIA) |
| 110 |
|
| 111 |
Pete Houston (openstrike, HOUSTON) |
| 112 |
|
| 113 |
Lukas Mai (MAUKE) |
| 114 |
|
| 115 |
=head1 COPYRIGHT AND LICENSE |
| 116 |
|
| 117 |
This software is copyright (c) 2015-2022 by Graham Ollis. |
| 118 |
|
| 119 |
This is free software; you can redistribute it and/or modify it under |
| 120 |
the same terms as the Perl 5 programming language system itself. |
| 121 |
|
| 122 |
=cut |