-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathBi.pm
More file actions
77 lines (53 loc) · 1.66 KB
/
Bi.pm
File metadata and controls
77 lines (53 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
=head1 NAME
LibBi - Bayesian inference for state-space models, including sequential Monte
Carlo (SMC), particle Markov chain Monte Carlo (PMCMC) and SMC^2 methods on
multithreaded, graphics processing unit (GPU) and distributed memory
architectures.
=head1 SYNOPSIS
use Bi qw(share_file share_dir);
=head1 METHODS
=over 4
=cut
package Bi;
use parent 'Exporter';
use warnings;
use strict;
our @EXPORT_OK = qw(share_file share_dir);
use FindBin qw($Bin);
use File::ShareDir qw(dist_file dist_dir);
use File::Spec;
=item B<share_file>(I<file>)
Returns a full path from which the shared file (not directory) I<file> can be
retrieved. A check for the existence of the file is made during the process.
=cut
sub share_file {
my $file = shift;
my $share_file = File::Spec->catfile($Bin, '..', 'share', $file);
if (!-e $share_file || !-f $share_file) {
$share_file = dist_file('LibBi', $file);
if (!-e $share_file || !-f $share_file) {
die("could not find shared file $file\n");
}
}
return $share_file;
}
=item B<share_dir>(I<dir>)
Returns a full path from which the shared directory I<dir> can be
retrieved. A check for the existence of the directory is made during the
process.
=cut
sub share_dir {
my $dir = shift;
my $share_dir = File::Spec->catdir($Bin, '..', 'share', $dir);
if (!-e $share_dir || !-d $share_dir) {
$share_dir = File::Spec->catdir(dist_dir('LibBi'), $dir);
if (!-e $share_dir || !-d $share_dir) {
die('could not find shared directory $dir\n')
}
}
return $share_dir;
}
1;
=back
=head1 AUTHOR
Lawrence Murray <lawrence.murray@csiro.au>