On Thu, Sep 06, 2001 at 12:57:43AM +0800, Philippe M . Chiasson wrote:
>
> Sure, also, I wonder what's the File::Spec clean way of canonical'izing a path
> name (i.e. removing all '.' , '..' and the same), because apparently abs2rel
s/abs2rel/rel2abs/
> just does something like :
>
> return $path if $path =~ m|^/|;
> return cwd . '/' . $path;
On Unix, that's all rel2abs() does, more or less (see below). Other
platforms are a bit trickier, due to volume semantics and syntax.
As for removing "name/.." sequences, I have some code around here that I
keep meaning to dust off and submit, but, as you point out "it's just
ugly".
- Barrie
sub rel2abs {
my ($self,$path,$base ) = @_;
# Clean up $path
if ( ! $self->file_name_is_absolute( $path ) ) {
# Figure out the effective $base and clean it up.
if ( !defined( $base ) || $base eq '' ) {
$base = cwd() ;
}
elsif ( ! $self->file_name_is_absolute( $base ) ) {
$base = $self->rel2abs( $base ) ;
}
else {
$base = $self->canonpath( $base ) ;
}
# Glom them together
$path = $self->catdir( $base, $path ) ;
}
return $self->canonpath( $path ) ;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]