File::Atomism::Protozoa - CAD drawing as an atomised directory


Draft documentation Contained in the Draft distribution.

Index


Code Index:

NAME

Top

File::Atomism::Protozoa - CAD drawing as an atomised directory

SYNOPSIS

Top

A directory that contains multiple drawing entities each represented by a single file.

DESCRIPTION

Top

A simple file-system directory/folder that contains any number of drawing objects, represented by files; and optionally, any number of further drawings represented by subdirectories.

Note that this is not completely analogous to a traditional monolithic CAD file format, as blocks/symbols associated with a drawing are complete drawings in their own right.

Files titled "DIRTYPE" or beginning with "." or "_" are not considered part of the data and are therefore ignored.

SGI::FAM (File Activation Monitor) is used to grapple the file list.


Draft documentation Contained in the Draft distribution.
package File::Atomism::Protozoa;

use strict;
use warnings;
use SGI::FAM;

sub Scan
{
    my $self = shift;
    my @freshfiles;
    my @stalefiles;

    $self->_init;

    while ($self->{_fam}->pending)
    {
        my $event = $self->{_fam}->next_event;

        push (@freshfiles, $event->filename)
            if ($event->type =~ /^(create|change|exist)$/);

        push (@stalefiles, $event->filename)
            if ($event->type eq 'delete');

        # mark for canvas erase if file changed or removed
        $File::Atomism::EVENT->{_old}->{$self->{_path} . $event->filename} = 'TRUE'
            if ($event->type =~ /^(change|delete)$/);

        # mark for canvas draw if file new or changed
        $File::Atomism::EVENT->{_new}->{$self->{_path} . $event->filename} = 'TRUE'
            if ($event->type =~ /^(create|change|exist)$/);
    }

    @stalefiles = grep (!/^(DIRTYPE$|[._])/, @stalefiles);
    @freshfiles = grep (!/^(DIRTYPE$|[._])/, @freshfiles);

    return \@freshfiles, \@stalefiles;
}

sub _init
{
    my $self = shift;
    unless ($self->{_fam})
    {
        $self->{_fam} = SGI::FAM->new;
        $self->{_fam}->monitor ($self->{_path});
    }
    return $self;
}

# FIXME: needs Clone(), Delete(), Journal() and Rename() methods for elements

}

1;