[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.8-25-g8c46684



The following commit has been merged in the master branch:
commit 8c46684c318a405b4e8062c568163788b7ff9bbb
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Jun 8 12:24:07 2012 +0200

    L::Path: Add basename and dirname
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/lib/Lintian/Collect/Package.pm b/lib/Lintian/Collect/Package.pm
index 83fdaec..4edbad8 100644
--- a/lib/Lintian/Collect/Package.pm
+++ b/lib/Lintian/Collect/Package.pm
@@ -167,14 +167,18 @@ sub _fetch_index_data {
         }
         $file{name} = $name = _dequote_name ($name);
 
+        $idxh{$name} = \%file;
+
         # Record children
         $children{$name} ||= [] if $file{type} eq 'd';
-        my ($parent) = ($name =~ m,^(.+/)?[^/]+/?$,);
+        my ($parent, $base) = ($name =~ m,^(.+/)?([^/]+/?)$,);
         $parent = '' unless defined $parent;
+        $base = '' unless defined $base;
+        $file{dirname} = $parent;
+        $file{basename} = $base;
         $children{$parent} = [] unless exists $children{$parent};
         push @{ $children{$parent} }, $name;
 
-        $idxh{$name} = \%file;
     }
     @sorted = sort keys %idxh;
     foreach my $file (@sorted) {
diff --git a/lib/Lintian/Path.pm b/lib/Lintian/Path.pm
index d28202c..a5895c2 100644
--- a/lib/Lintian/Path.pm
+++ b/lib/Lintian/Path.pm
@@ -141,9 +141,28 @@ NB: This is only well defined for file entries that are subject to
 permissions (e.g. files).  Particularly, the value is not well defined
 for symlinks.
 
+=item dirname
+
+Returns the "directory" part of the name, similar to dirname(1) or
+File::Basename::dirname.  The dirname will end with a trailing slash
+(except the "root" dir - see below).
+
+NB: Returns the empty string for the "root" dir.
+
+=item basename
+
+Returns the "filename" part of the name, similar basename(1) or
+File::Basename::basename (without passing a suffix to strip in either
+case).  For dirs, the basename will end with a trailing slash (except
+for the "root" dir - see below).
+
+NB: Returns the empty string for the "root" dir.
+
 =cut
 
-Lintian::Path->mk_ro_accessors (qw(name owner group link type uid gid size date operm));
+Lintian::Path->mk_ro_accessors (qw(name owner group link type uid gid
+  size date operm dirname basename
+));
 
 =item children
 

-- 
Debian package checker


Reply to: