Changeset 10531
- Timestamp:
- Dec 7, 2006, 12:47:12 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-Config/lib/PS/IPP/Config.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
r10467 r10531 1 1 # Copyright (c) 2006 Paul Price, Joshua Hoblitt 2 2 # 3 # $Id: Config.pm,v 1.1 1 2006-12-05 03:15:03price Exp $3 # $Id: Config.pm,v 1.12 2006-12-07 22:47:12 price Exp $ 4 4 5 5 package PS::IPP::Config; … … 97 97 my $name = shift; # datapath name 98 98 99 my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of cameras100 my $pathname = _mdLookupStr($path_list, $name); # Filename of camera configuration99 my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths 100 my $pathname = _mdLookupStr($path_list, $name); # Path of interest 101 101 croak "Unable to find camera configuration file $pathname\n" if not defined $pathname; 102 102 … … 104 104 } 105 105 106 sub convert_filename 106 sub convert_filename_absolute 107 107 { 108 108 my $self = shift; # Configuration object … … 123 123 } 124 124 125 # if we have a relative path in the end, prepend WORKDIR 126 unless ($name =~ m|^/|) { 127 my $workdir = $self->workdir(); 128 if (defined $workdir) { 129 $name = File::Spec->rel2abs( $name, $workdir ); 130 } 125 $name =~ s|/{2,}|/|g; # Remove double slashes 126 127 return $name; 128 } 129 130 sub convert_filename_relative 131 { 132 my $self = shift; # Configuration object 133 my $name = shift; # raw name 134 135 $name =~ s|/{2,}|/|g; # Remove double slashes 136 137 my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths 138 my $best_path; 139 my $best_name; 140 my $best_score = length $name; 141 foreach my $path_item (@$path_list) { 142 my $path_name = $path_item->{name}; # Name of the path 143 my $path = $path_item->{value}; # The path 144 if ($path !~ m|/$|) { 145 $path .= '/'; 146 } 147 my ($rest) = $name =~ m|^$path(.*)|; # Rest of the string 148 next if not defined $rest; 149 my $score = length $rest; 150 if ($score < $best_score) { 151 $best_path = $path; 152 $best_score = $score; 153 $best_name = $path_name; 154 } 155 } 156 if ($best_score < length $name) { 157 $name =~ s|^$best_path|path://$best_name/|; 158 } else { 159 # Worst case scenario: can't find anything, so put in the absolute path 160 $name = 'file://' . $name; 131 161 } 132 162
Note:
See TracChangeset
for help on using the changeset viewer.
