Youri::Package::File - Package file class


Youri-Package documentation Contained in the Youri-Package distribution.

Index


Code Index:

NAME

Top

Youri::Package::File - Package file class

DESCRIPTION

Top

This class represent a package file,

CLASS METHODS

Top

new(%args)

Creates and returns a new Youri::Package::File object.

get_name()

Returns the name of this file.

get_mode()

Return the mode of this file.

get_md5sum()

Return the md5sum of this file.

is_directory()

Returns a true value if this file is a directory.


Youri-Package documentation Contained in the Youri-Package distribution.
# $Id: File.pm 1462 2007-02-12 20:56:03Z guillomovitch $
package Youri::Package::File;

use strict;
use warnings;
use Carp;

use constant NAME   => 0;
use constant MODE   => 1;
use constant MD5SUM => 2;

use constant MODE_MASK => oct(170000); 
use constant MODE_DIR  => oct(40000);

sub new {
    my ($class, $name, $mode, $md5sum) = @_;

    return bless [
        $name,
        $mode,
        $md5sum,
    ], $class;
}

sub get_name {
    my ($self) = @_;
    croak "Not a class method" unless ref $self;

    return $self->[NAME];
}

sub get_mode {
    my ($self) = @_;
    croak "Not a class method" unless ref $self;

    return $self->[MODE];
}

sub get_md5sum {
    my ($self) = @_;
    croak "Not a class method" unless ref $self;

    return $self->[MD5SUM];
}

sub is_directory {
    my ($self) = @_;
    croak "Not a class method" unless ref $self;

    return ($self->[MODE] & MODE_MASK) == MODE_DIR;
}

1;