OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/perl |
| 2 use strict; |
| 3 use warnings; |
| 4 use Exporter; |
| 5 |
| 6 package idltopath; |
| 7 |
| 8 our @ISA = qw( Exporter ); |
| 9 # our @EXPORT_OK = qw( export_me export_me_too ); |
| 10 # These are exported by default. |
| 11 our @EXPORT = qw( idl_to_path idlToPath ); |
| 12 |
| 13 my %idlToPathHash; |
| 14 sub idlToPath |
| 15 { |
| 16 if (!%idlToPathHash) { |
| 17 my $idlToPathFile = $ENV{"IDLTOPATHFILE"}; |
| 18 die "Missing environment variable IDLTOPATHFILE" if !$idlToPathFile; |
| 19 print "Opening " . $idlToPathFile; |
| 20 open(FILE, $idlToPathFile) || die; |
| 21 while (<FILE>) |
| 22 { |
| 23 my ($key, $val) = split /,/; |
| 24 # Strip CRLF from val (chomp is picky and will often remove only hal
f). |
| 25 $val =~ s/\s*$//; |
| 26 $idlToPathHash{$key} .= $val; |
| 27 } |
| 28 |
| 29 die if !%idlToPathHash; |
| 30 } |
| 31 |
| 32 my $interface = shift; |
| 33 if ($idlToPathHash{$interface}) { |
| 34 return $idlToPathHash{$interface} . '/'; |
| 35 } elsif ($interface =~ /^SVGPath/ && $idlToPathHash{$interface . "Abs"}) { |
| 36 return $idlToPathHash{$interface . "Abs"} . '/'; |
| 37 } else { |
| 38 return 'fixmebratell89/'; |
| 39 } |
| 40 } |
| 41 |
| 42 |
| 43 sub idl_to_path |
| 44 { |
| 45 my $interface = shift; |
| 46 return idlToPath($interface) |
| 47 } |
| 48 1; |
OLD | NEW |