NAME

Fuse::PDF::FS - In-PDF implementation of a filesystem.

SYNOPSIS

use Fuse::PDF::FS;
my $fs = Fuse::PDF::FS->new({pdf => CAM::PDF->new('my_doc.pdf')});
$fs->fs_mkdir('/foo');
$fs->fs_write('/foo/bar', 'Hello world!', 0);
$fs->save();

LICENSE

Copyright 2007 Chris Dolan, cdolan@cpan.org

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

DESCRIPTION

This is an implementation of a filesystem inside of a PDF file. Contrary to the package name, this module is actually independent of FUSE, but is meant to map cleanly onto the FUSE API. See Fuse::PDF and the mount_pdf front-end.

METHODS

$pkg->new($hash_of_options)

Create a new filesystem instance. This method creates a new root filesystem node in the PDF if one does not already exist. The only required option is the pdf key, like so:

my $fs = Fuse::PDF::FS->new({pdf => $pdf});

Supported options:

pdf => $pdf

Specify a CAM::PDF instance. Fuse::PDF::FS is highly dependent on the architecture of CAM::PDF, so swapping in another PDF implementation is not likely to be feasible with substantial rewriting or bridging.

compact => $boolean

Specifies whether the PDF should be compacted upon save. Defaults to true. If this option is turned off, then previous revisions of the filesystem can be retrieved via standard PDF revert tools, like revertpdf.pl from the CAM::PDF distribution. But that can lead to rather large PDFs.

autosave_filename => undef | $filename

If this option is set to a filename, the PDF will be automatically saved when this instance is garbage collected. Otherwise, the client must explicitly call save(). Defaults to undef.

fs_name => $name

This specifies the key where the filesystem data is stored inside the PDF data structure. Defaults to 'FusePDF_FS', Note that it is possible to have multiple independent filesystems embedded in the same PDF at once by choosing another name. However, mounting more than one at a time will almost certainly cause data loss.

$self->save($filename);

Explicitly trigger a save to the specified filename. If autosave_filename is defined, then this method is called via DESTROY().

$self->autosave_filename()
$self->autosave_filename($filename)

Accessor/mutator for the autosave_filename property described above.

$self->compact()
$self->compact($boolean)

Accessor/mutator for the compact property described above.

FUSE-COMPATIBLE METHODS

The following methods are independent of Fuse, but uses almost the exact same API expected by that package (except for fs_setxattr), so they can easily be converted to a FUSE implementation.

$self->fs_getattr($file)
$self->fs_readlink($file)
$self->fs_getdir($file)
$self->fs_mknod($file, $modes, $dev)
$self->fs_mkdir($file, $perms)
$self->fs_unlink($file)
$self->fs_rmdir($file)
$self->fs_symlink($link, $file)
$self->fs_rename($oldfile, $file)
$self->fs_link($srcfile, $file)
$self->fs_chmod($file, $perms)
$self->fs_chown($file, $uid, $gid)
$self->fs_truncate($file, $length)
$self->fs_utime($file, $atime, $utime)
$self->fs_open($file, $mode)
$self->fs_read($file, $size, $offset)
$self->fs_write($file, $str, $offset)
$self->fs_statfs()
$self->fs_flush($file)
$self->fs_release($file, $mode)
$self->fs_fsync($file, $flags)
$self->fs_setxattr($file, $key, $value, \%flags)
$self->fs_getxattr($file, $key)
$self->fs_listxattr($file)
$self->fs_removexattr($file, $key)

SEE ALSO

Fuse::PDF

CAM::PDF

AUTHOR

Chris Dolan, cdolan@cpan.org