From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM"  6-JUN-1994 10:16:20.09
To:	EVERHART
CC:	
Subj:	Re: Is xxx.dir a directory ?

From: lane@duphy4.drexel.edu (Charles Lane)
X-Newsgroups: comp.os.vms
Subject: Re: Is xxx.dir a directory ?
Message-Id: <1994Jun1.162023.1875@duphy4>
Date: 1 Jun 94 16:20:23 -0400
Distribution: world
Organization: Drexel University Physics
Lines: 48
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET

In article <2sibif$hnc@gap.cco.caltech.edu>, carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick) writes:
>
> As best I can tell, you can't get the information via a lexical (at least not
> under VMS v5.4-2).  Here's a program that works properly.  If the file is a
> directory, it exits with a status of 1.  Otherwise, it exits with either:

[nice program deleted...]

I remember having to cook up a program similar to the one Carl posted,
although less elegant.  Now, however, one can get the information from
the fstat function in the C run-time library (VMS V6.0, in case that
matters)

The program below is much more primitive than Carl's, but it shows
how to use fstat to get the "directory" bit.  I checked, and it does
know directories even when they are named "foo.bar" and are not faked
out by non-directory files with .DIR extensions.


/*
    test fstat

*/
#include <unixio>
#include <file>
#include <stat>

main()
{
    int fd, isadir;
    char buf[1000];
    stat_t stats;

    printf("enter filename: ");
    gets(buf);

    fd = open(buf,O_RDONLY,0);
    fstat(fd, &stats);
    isadir = (stats.st_mode & S_IFDIR) != 0;
    printf("directory? %d\n",isadir);
}



--
Chuck Lane                              "I wish to God these calculations
Drexel Univ. Particle Physics           had been accomplished by steam."
lane@duphy4.physics.drexel.edu          --C. Babbage

