From 6e1210d3e55f807c8deee0d5ba46543d925b076d Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 13 Nov 2006 10:38:31 +0000 Subject: add dirname() --- urpm/util.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'urpm') diff --git a/urpm/util.pm b/urpm/util.pm index f23c2076..ed1f885d 100644 --- a/urpm/util.pm +++ b/urpm/util.pm @@ -9,7 +9,7 @@ our @EXPORT = qw(quotespace unquotespace remove_internal_name reduce_pathname offset_pathname md5sum untaint - difference2 member file_size cat_ basename + difference2 member file_size cat_ dirname basename ); (our $VERSION) = q($Revision$) =~ /(\d+)/; @@ -19,6 +19,7 @@ sub quotespace { my $x = $_[0] || ''; $x =~ s/(\s)/\\$1/g; $x } sub unquotespace { my $x = $_[0] || ''; $x =~ s/\\(\s)/$1/g; $x } sub remove_internal_name { my $x = $_[0] || ''; $x =~ s/\(\S+\)$/$1/g; $x } +sub dirname { local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' } sub basename { local $_ = shift; s|/*\s*$||; s|.*/||; $_ } #- reduce pathname by removing /.. each time it appears (or . too). -- cgit v1.2.1