Changeset 13317
- Timestamp:
- May 9, 2007, 4:35:36 PM (19 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
r13297 r13317 1 1 # Copyright (c) 2006 Paul Price, Joshua Hoblitt 2 2 # 3 # $Id: Config.pm,v 1.4 4 2007-05-07 21:03:10price Exp $3 # $Id: Config.pm,v 1.45 2007-05-10 02:35:36 price Exp $ 4 4 5 5 package PS::IPP::Config; … … 170 170 my @segments = @_; # Path segments 171 171 172 my $old = URI->new( $base ) or die "Unable to parse URI: $base\n"; # URI173 $ old = $old->canonical(); # Clean up174 my $ scheme = $old->scheme(); # Scheme, e.g., file, path175 unshift @segments, $old->path_segments(); 176 177 for (my $i = 0; $i < scalar @segments; $i++) { 178 splice( @segments, $i--, 1 ) unless $segments[$i] =~ /\S+/; 179 }180 181 my $new = URI->new(); # URI to return 182 $new->scheme( $scheme );183 $new->authority( $old->authority() ); 184 185 # Catch "neb:", "neb:/" and "neb://" for the base name186 my $opaque = $old->opaque();187 unshift( @segments, '', '' ) if $opaque eq '' or $opaque eq '/' or $opaque eq '//';188 $new->opaque( '/') if $old->opaque() eq '//';189 190 $new->path_segments( @segments );191 192 return $ new->canonical()->as_string();172 my ($scheme) = $base =~ m|^(\S+):|; # The scheme, e.g., file://, path:// 173 $base =~ s|^\S+:/*||; 174 my $root = '/' if $base =~ m|^/|; # Any root slashes? 175 176 unshift @segments, $base if $base =~ /\S+/; 177 178 # Remove leading and trailing slashes 179 foreach my $segment ( @segments ) { 180 $segment =~ s|^/*||; 181 $segment =~ s|/*$||; 182 } 183 184 # Join everything together 185 my $joined = join('/', @segments); 186 if (defined $scheme) { 187 $joined = $scheme . "://" . $joined; 188 } else { 189 $joined = $root . $joined; 190 } 191 192 return $joined; 193 193 } 194 194 … … 388 388 my $template = shift; # Template filename from which to get working directory if 389 389 390 my $resolved = $name; # Resolved version of file name 390 391 if (defined $workdir) { 391 $ name= caturi( $workdir, $name );392 $resolved = caturi( $workdir, $name ); 392 393 } elsif (defined $template) { 393 394 # Take directory from template and apply to name 394 395 my $dir = _strip_filename( $template ); 395 $ name= caturi( $dir, $name );396 $resolved = caturi( $dir, $name ); 396 397 } 397 398 … … 401 402 402 403 # Might need to create a directory 403 $ name = $self->convert_filename_absolute( $name);404 my ( $vol, $dirs, $file ) = File::Spec->splitpath( $ name);404 $resolved = $self->convert_filename_absolute( $resolved ); 405 my ( $vol, $dirs, $file ) = File::Spec->splitpath( $resolved ); 405 406 system "mkdir -p $dirs"; 406 407
Note:
See TracChangeset
for help on using the changeset viewer.
