Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How *do* they do that?

by abstracts (Hermit)
on Aug 12, 2001 at 13:56 UTC ( [id://104222]=note: print w/replies, xml ) Need Help??


in reply to How does Perl handle opendir/readdir/closedir internally?

Hello

If you look at the opendir(3) manpage, you will see that perl's opendir, readdir and closedir are handled directly by their C counterparts. The DIR * data type is defined I believe in dirent.h or in sys/types.h.

I believe implementing opendir, readdir and closedir are straightforward in XS given that this is their calling syntax:

DIR *opendir(const char *name); int closedir(DIR *dir); struct dirent *readdir(DIR *dir);

Did I answer the question?

Aziz,,,

Replies are listed 'Best First'.
Re: Re: How *do* they do that?
by gellyfish (Monsignor) on Aug 12, 2001 at 17:20 UTC

    In an XS program it appears that it is slightly more complicated than this as the XSUB.h for perl 5.72 has :

    # define opendir PerlDir_open

    having previously undefined opendir.

    PerlDir_open itself is defined in iperlsys.h in 5.72 - this is so that it can be made to fit in with the whole PerlIO thing.

    Probably the easiest way of finding out what is going on in here is to look at the implementation of pp_open_dir in pp_sys.c and then work backward from there.

    /J\

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://104222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found