Lintian::Path - Lintian representation of a path entry in a package
my ($name, $type, $dir) = ('lintian', 'source', '/path/to/entry'); my $info = Lintian::Collect->new ($name, $type, $dir); my $path = $info->index('bin/ls'); if ($path->is_file) { # is file (or hardlink) if ($path->is_hardlink) { } if ($path->is_regular_file) { } } elsif ($path->is_dir) { # is dir if ($path->owner eq 'root') { } if ($path->group eq 'root') { } } elsif ($path->is_symlink) { my $normalized = $path->link_normalized; if (defined($normalized)) { my $more_info = $info->index($normalized); if (defined($more_info)) { # target exists in the package... } } }
Internal constructor (used by Lintian::Collect::Package).
Argument is a hash containing the data read from the index file.
Returns the name of the file (relative to the package root).
NB: It will never have any leading "./" (or "/") in it.
Returns the owner of the path entry as a username.
NB: If only numerical owner information is available in the package, this may return a numerical owner (except uid 0 is always mapped to "root")
Returns the group of the path entry as a username.
NB: If only numerical owner information is available in the package, this may return a numerical group (except gid 0 is always mapped to "root")
Returns the uid of the owner of the path entry.
NB: If the uid is not available, undef will be returned. This usually happens if the numerical data is not collected (e.g. in source packages)
Returns the gid of the owner of the path entry.
NB: If the gid is not available, undef will be returned. This usually happens if the numerical data is not collected (e.g. in source packages)
If this is a link (i.e. is_symlink or is_hardlink returns a truth value), this method returns the target of the link.
If this is not a link, then this returns undef.
If the path is a symlink this method can be used to determine if the symlink is relative or absolute. This is not true for hardlinks, where the link target is always relative to the root.
NB: Even for symlinks, a leading "./" will be stripped.
Returns the size of the path in bytes.
NB: This is only well defined for files.
Return the modification date as YYYY-MM-DD.
Returns the file permissions of this object in octal (e.g. 0644).
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.
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.
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.
Returns a list of children (as Lintian::Path objects) of this entry. The list and its contents should not be modified.
NB: Returns the empty list for non-dir entries.
Returns a truth value if this entry is a symlink.
Returns a truth value if this entry is a hardlink to a regular file.
NB: The target of a hardlink is always a regular file (and not a dir etc.).
Returns a truth value if this entry is a dir.
NB: Unlike the "-d $dir" operator this will never return true for symlinks, even if the symlink points to a dir.
Returns a truth value if this entry is a regular file (or a hardlink to one).
NB: Unlike the "-f $dir" operator this will never return true for symlinks, even if the symlink points to a file (or hardlink).
Returns a truth value if this entry is a regular file.
This is eqv. to $path->is_file and not $path->is_hardlink.
NB: Unlike the "-f $dir" operator this will never return true for symlinks, even if the symlink points to a file.
Returns the target of the link normalized against it's directory name. If the link cannot be normalized or normalized path might escape the package root, this method returns undef
.
NB: This method will return the empty string for links pointing to the root dir of the package.
Only available on "links" (i.e. symlinks or hardlinks). On non-links this will croak.
CAVEAT: This method is not always sufficient to test if it is safe to open a given symlink. Use is_ancestor_of for that. If you must use this method, remember to check that the target is not a symlink (or if it is, that it can be resolved safely).
Originally written by Niels Thykier <niels@thykier.net> for Lintian.
lintian(1), Lintian::Collect(3), Lintian::Collect::Binary(3), Lintian::Collect::Source(3)