Path: utzoo!utgpu!attcan!uunet!husc6!cmcl2!nrl-cmf!ames!necntc!necis!mrst!apollo!mishkin
From: mishkin@apollo.COM (Nathaniel Mishkin)
Newsgroups: comp.sys.apollo
Subject: Re: How does ios_dir_$open work?
Message-ID: <3ddf9138.13422@apollo.COM>
Date: 15 Aug 88 13:22:00 GMT
References: <8808122122.AA14782@mailgw.cc.umich.edu>
Reply-To: mishkin@apollo.com (Nathaniel Mishkin)
Organization: Apollo Computer, Chelmsford, MA
Lines: 54


         I have been trying to write a program to walk through a directory,
         and get the full path name of every object recorded there.  Much
         of it works, but I have been unable to open objects based on
         an open directory stream.  The code at fault resembles the
         following, which also displays the problem: ...

         So, why is it an illegal operation to perform an "ios_dir_$open"
         on an Apollo directory object that purports to implement the
         IOS_DIR trait?

    That's easy -- the dir_open operation is not implemented for the
    apollo_dir type.

I hasten to point out that the program can be written (probably more
simply) using chdir and opendir/readdir:

---------------------------------------------------

#include "/sys/ins/base.ins.c"
#include "/sys/ins/ios.ins.c"

#include 
#include 
#include 

main(argc, argv)
int argc;
char *argv[];
{
    DIR *dir;
    struct direct *ent;
    int fd;
    char pname[1024];
    short pnamelen;
    status_$t st;

    chdir(argv[1]);
    dir = opendir(".");

    while ((ent = readdir(dir)) != NULL) {
        fd = open(ent->d_name, O_RDONLY, 0);
        ios_$inq_path_name((short) fd, ios_$root_name, pname, pnamelen, st);
        close(fd);
        printf("%.*s\n", pnamelen, pname);
    }
}

---------------------------------------------------

-- 
                    -- Nat Mishkin
                       Apollo Computer Inc., Chelmsford, MA
                       mishkin@apollo.com