NAME

Data::Embed::File - embed arbitrary data in a file

DESCRIPTION

Accessor class for representing an embedded file (for reading).

METHODS

contents

my $string = $def->contents();

Convenience method to slurp the whole contents of the embedded file in one single shot. It always provides the full contents, independently of whether data had been read before, although it restores the filehandle to the previous position.

fh

my $fh = $def->fh();

Get a filehandle suitable for accessing the embedded file. It provides back a filehandle through IO::Slice, providing the illusion of working on a file per-se instead of a slice inside a bigger file.

is_same_as

$def->is_same_as($other_def);

Test whether the specific Data::Embed::File is the same as some $other_def.

name

my $name = $def->name();

Get the name associated to the file, whatever it is. Data::Embed::Reader sets it from what is read in the index file

new

my $def = Data::Embed::File->new(%args); # OR
my $def = Data::Embed::File->new(\%args);

Constructor. It will act lazily, just storing the input data for later usage by other methods, providing validation.

Input data can be provided as key-value pairs of through a reference to a hash.

For proper functioning of the object, the following keys should be provided:

fh

a filehandle for the stream where the data are contained

filename

the name of the file where the data are. This parameter is optional if fh above is already provided.

offset

the offset within the stream where the real data for this file begins. 0 means the very beginning of the file.

length

the length of the data belonging to this File.

AUTHOR

Flavio Poletti <polettix@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2014-2016 by Flavio Poletti <polettix@cpan.org>

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.