summaryrefslogtreecommitdiffstats
path: root/urpm/util.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-13 10:38:31 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-13 10:38:31 +0000
commit6e1210d3e55f807c8deee0d5ba46543d925b076d (patch)
tree0deaa0cf8579e01e7cbacb20628215a52def78da /urpm/util.pm
parentc6fdae076c296fc717c33b6bb2fb84d586bbf125 (diff)
downloadurpmi-6e1210d3e55f807c8deee0d5ba46543d925b076d.tar
urpmi-6e1210d3e55f807c8deee0d5ba46543d925b076d.tar.gz
urpmi-6e1210d3e55f807c8deee0d5ba46543d925b076d.tar.bz2
urpmi-6e1210d3e55f807c8deee0d5ba46543d925b076d.tar.xz
urpmi-6e1210d3e55f807c8deee0d5ba46543d925b076d.zip
add dirname()
Diffstat (limited to 'urpm/util.pm')
-rw-r--r--urpm/util.pm3
1 files changed, 2 insertions, 1 deletions
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 <something>/.. each time it appears (or . too).