Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

could be directory "virtualized" from perl, like PerlIO but for directories?

by vkon (Curate)
on Feb 06, 2011 at 19:35 UTC ( #886541=perlquestion: print w/ replies, xml ) Need Help??
vkon has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Everyone knows that perl IO could be "intercepted" using PerlIO layer, i.e. one could create file handle that is mapped into memory (or anywhere else)

Is it possible for directories?

Something like Tie::TextDir - but other way round - Tie::TextDir maps directory to tied perl hash, but I want the opposite - any read of said directory should consult my hash (or just call my callback).

To say, tcl/tk have this mechanics.
I wonder - does perl have this possibility?

TIA,
vkon

Comment on could be directory "virtualized" from perl, like PerlIO but for directories?
Replies are listed 'Best First'.
Re: could be directory "virtualized" from perl, like PerlIO but for directories?
by snoopy (Deacon) on Feb 07, 2011 at 05:00 UTC
    On the heavy side, Fuse::Simple lets you map a file system to Perl hashes.

    FUSE is implemented at the OS level rather than being Perl specific. it doesn't require root access, but does need a server process (or at least a thread).

    The files are really mounted and are visible to Perl and other processes. It's a deeper abstraction which may or may not be what you want.

    As a final catch, the underlaying Fuse module claims to only work well under Linux or BSD. FUSE however is widely available on other platforms, including Windows.

    I just thought it might be of interest. See also the wikipedia entry Filesystem_in_Userspace.

Re: could be directory "virtualized" from perl, like PerlIO but for directories?
by ikegami (Pope) on Feb 07, 2011 at 03:19 UTC
    Globally overriding opendir and readdir might do what you are trying to do. It won't affect XS modules, though.
Re: could be directory "virtualized" from perl, like PerlIO but for directories?
by Anonymous Monk on Feb 07, 2011 at 00:14 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://886541]
Approved by planetscape
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2015-08-27 22:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (334 votes), past polls