Changeset 10568 for trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
- Timestamp:
- Dec 8, 2006, 9:41:12 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-Config/lib/PS/IPP/Config.pm (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
r10566 r10568 1 1 # Copyright (c) 2006 Paul Price, Joshua Hoblitt 2 2 # 3 # $Id: Config.pm,v 1.1 4 2006-12-08 18:51:24price Exp $3 # $Id: Config.pm,v 1.15 2006-12-08 19:41:12 price Exp $ 4 4 5 5 package PS::IPP::Config; … … 113 113 my $scheme = $uri->scheme(); # Scheme, e.g., file, path 114 114 if (lc($scheme) eq 'file') { 115 return File::Spec->canonpath( $uri->path() ); 115 my $host = $uri->host(); 116 my $path; 117 if (defined $host) { 118 # The user has file://some/directory/ but *probably* wants 119 # /some/directory/ i.e., the URI is technically wrong 120 # (should be one or three leading slashes, not two). We 121 # choose to fix it and give the user what we think they 122 # want, rather than what they asked for. 123 $path = File::Spec->catfile( undef, $blah, $uri->path() ); 124 } else { 125 $path = $uri->path(); 126 } 127 128 return File::Spec->canonpath( $path ); 116 129 } 117 130 118 131 if (lc($scheme) eq 'path') { 132 my $authority = $uri->authority(); 133 my $path = $self->datapath( $authority ); 119 134 my @segments = $uri->path_segments(); 120 my $source = shift @segments; 121 my $path = $self->datapath( $source ); 122 my $rel = File::Spec->catfile( @segments ); 123 return File::Spec->rel2abs( $rel, $path ); 135 return File::Spec->catfile( $path, @segments ); 124 136 } 125 137 … … 135 147 my ($vol, $dir, $file) = File::Spec->splitpath( $name ); 136 148 my @dirs = File::Spec->splitdir( $dir ); 149 pop @dirs; # Get rid of filename 137 150 138 151 my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths … … 140 153 my $best_name; 141 154 my $best_score; 142 PATH_CHECK: foreach my $path_item (@$path_list) {155 CFR_PATH_CHECK: foreach my $path_item (@$path_list) { 143 156 my $path_name = $path_item->{name}; # Name of the path 144 my $path = $path_item->{value}; # The path157 my $path = File::Spec->canonpath( $path_item->{value} ); # The path 145 158 my @path_dirs = File::Spec->splitdir( $path ); 146 159 … … 148 161 next if scalar @path_dirs > scalar @dirs; 149 162 for (my $i = 0; $i < scalar @path_dirs; $i++) { 150 next PATH_CHECK if $path_dirs[$i] ne $dirs[$i];163 next CFR_PATH_CHECK if $path_dirs[$i] ne $dirs[$i]; 151 164 } 152 165 # It is suitable; see if it is 'best' (minimizes the number of directories) 153 166 my $score = scalar @path_dirs; 154 if ( $score > $best_score) {167 if (not defined $best_score or $score > $best_score) { 155 168 $best_path = $path; 156 169 $best_score = $score; … … 161 174 if (defined $best_score) { 162 175 my $rel = File::Spec->abs2rel( $name, $best_path ); 176 my @segments = File::Spec->splitdir( $rel ); 163 177 $uri->scheme( 'path' ); 164 $uri->path_segments( $best_name, $rel ); 178 $uri->authority( $best_name ); 179 $uri->path_segments( @segments ); 165 180 } else { 166 181 $uri->scheme( 'file' );
Note:
See TracChangeset
for help on using the changeset viewer.
