Fuse::PDF::FS - In-PDF implementation of a filesystem.
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();
Copyright 2007-2008 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.
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.
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:
pdf
my $fs = Fuse::PDF::FS->new({pdf => $pdf});
Supported options:
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.
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.
undef
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.
save()
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.
Specifies whether to save the previous version of the PDF as $filename.bak before saving a new version. Defaults to false.
Accessor/mutator for the autosave_filename property described above.
autosave_filename
Accessor/mutator for the compact property described above.
compact
Accessor/mutator for the backup property described above.
backup
Explicitly trigger a save to the specified filename. If autosave_filename is defined, then this method is called via DESTROY().
DESTROY()
Delete the filesystem from the in-memory PDF and save the result to the specified filename. If there is more than one filesystem in the PDF, only the one indicated by the fs_name above is affected. If no filesystem exists with that fs_name, the save succeeds anyway.
fs_name
Return a list of one instance for each revision of the PDF. The first item on the list is this instance (the newest) and the last item on the list is the first revision of the PDF (the oldest).
If there is an older version of the PDF, extract that and return a new Fuse::PDF::FS instance which applies to that revision. Multiple versions is feature supported by the PDF specification, so this action is consistent with other PDF revision editing tools.
Fuse::PDF::FS
If this is a new filesystem or if the compact() option was used, then there will be no previous revisions and this will return undef.
compact()
Return a hashref with some global information about the filesystem. This is currently meant for humans and the exact list of statistics is not yet locked down. See the code for more details.
Return a human-readable representation of the statistics for each revision of the filesystem.
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.
POSIX is missing a constant this error number (at least, not on Mac 10.4). If we detect that it is missing at runtime, we attempt to replace it by: 1) reading errno.h, 2) falling back to EIO.
See Fuse::PDF::ErrnoHacks.
Fuse::PDF
CAM::PDF
Chris Dolan, cdolan@cpan.org
To install Fuse::PDF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fuse::PDF
CPAN shell
perl -MCPAN -e shell install Fuse::PDF
For more information on module installation, please visit the detailed CPAN module installation guide.