Eryq > MIME-tools-6.200_02 > MIME::Parser::TreeFiler

Download:
MIME-tools-6.200_02.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  13
Open  8
View Bugs
Report a bug
Source  

NAME ^

MIME::Parser::TreeFiler - file messages into a directory tree

SYNOPSIS ^

    ### Place message parts in subdirectories of "/tmp/msgs":
    $filer = MIME::Parser::TreeFiler->new("/tmp/msgs");  
    $parser->filer($filer);

DESCRIPTION ^

This concrete subclass of MIME::Parser::Filer supports filing under a given directory, using one subdirectory per message, but with all message parts in the same directory.

PUBLIC INTERFACE ^

init BASEDIR

Instance method, initiallizer. Set the base directory which will contain the message directories. If used, then each parse of begins by creating a new subdirectory under BASEDIR where the actual parts of the message are placed.

base_dir

Instance method. Return the base directory we were created with, which is the parent of the directories created for each individual message.

create_message_subdirectory_name

Instance method, for subclasses only. A new message is being parsed; synthesize a name of a new subdirectory under the "base_dir" where the message will be placed.

The default creates a name like:

    msg-{unixtime}-{process id}-{sequence number}

If you don't like this, subclass and override.

last_message_dir

Instance method. Return the last message directory set up by init_parse(). This lets you write code like this:

    $filer = new MIME::Parser::TreeFiler->("/tmp");
    $parser->filer($filer);
    ...
    $ent = eval { $parser->parse_open($msg); };   
    if (!$ent) {         ### parse failed
        die "parse failed: garbage is in ".$parser->last_message_dir."\n";
        ...
    } 
    else {               ### parse succeeded
        ...do stuff...
    }
output_dir HEAD

Instance method, override. Returns the output directory for the entity with the given HEAD; this will be used by output_path() to create the full path needed by the MIME::Parser.