NAME
File::Redirect - override native perl file oprations
SYNOPSIS
$ unzip -l Foo-Bar-0.01.zip
Archive: Foo-Bar-0.01.zip
Length Date Time Name
-------- ---- ---- ----
0 02-25-12 07:46 Foo-Bar-0.01/
0 02-25-12 07:47 Foo-Bar-0.01/lib/
0 02-25-12 07:47 Foo-Bar-0.01/lib/Foo/
43 02-25-12 07:47 Foo-Bar-0.01/lib/Foo/Bar.pm
-------- -------
43 4 files
$ unzip -p Foo-Bar-0.01.zip Foo-Bar-0.01/lib/Foo/Bar.pm
package Foo::Bar;
sub foo { 42 }
1;
$ cat test.pl
use File::Redirect::lib ('Zip', 'Foo-Bar-0.01.zip', '/Foo-Bar-0.01/lib');
use Foo::Bar;
print Foo::Bar::foo(), "\n";
$ perl test.pl
42
DESCRIPTION
Perl's own use and require cannot be overloaded so that underlying file requests are mapped to something else. This module hacks IO layer system so that one can fool Perl's IO into thinking that it operates on files while feeding something else, for example archives.
The framework currently overrides only stat and open builtins, which is enough for hacking into use and require. The framework though is capable of being extended to override other file- and dir- based operations, but that's probably is easier to do separately by overriding *CORE::GLOBAL:: functions.
Warning: works only if perl's PERL_IMPLICIT_SYS is enabled
API
- mount $provider, $request, $as_path
-
Similar to unix mount(1) command, the function 'mounts' an abstract data entity ($request) into file path $as_path by sending it to $provider. For example, provider
Simpletreats request as path-content hash. After this commandmount( 'Simple', { 'a' => 'b' }, 'simple:')reading from file 'simple:a' yield 'b' as its content. See also File::Redirect::Zip.
The function return success flag; on failure, $@ contains the error.
- umount $path
-
Removes data entity associated with $path.
AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>.