Everhart, Glenn From: Nigel White [Nigel.White@synergex.com] Sent: Monday, November 30, 1998 6:07 PM To: Info-VAX@Mvb.Saic.Com Subject: RE: Is this file a directory? Thanks Arthur, I thought that was a nice little routine, so I decided to translate it into C, and save it as an example of how to use the XABITM xab block. Now, don't flame me. This little program runs when the debugger is present, but displays zero for both files when run /NODEBUG. Yes, yes, I know this just means that the debugger masked a memory problem of my own making by shifting things around, but even with that knowledge, I can't spot my "deliberate" mistake. Can anyone help.... Here is the C code: /* DESCRIPTION : Is the specified file a directory? INPUT ARGUMENTS : filename - the name of the file to check OUTPUT ARGUMENTS : is_dir - <>0 if the file is a directory 0 if not or error */ #include #include #include #include #include __int32 isdir(filename) char *filename; { __int32 status, dir_flag; struct xabitmdef xab; struct fabdef fab; typedef struct { __int16 buflen; __int16 itemcode; void *bufadr; __int16 *retlen; } itmlst; itmlst items[2]; /* --- initialize FAB */ fab = cc$rms_fab; fab.fab$l_fna = filename; fab.fab$b_fns = strlen(filename); fab.fab$b_fac = FAB$M_GET; fab.fab$l_xab = (char *)&xab; /* --- initialize XAB (being lazy about named fields) */ xab.xab$b_cod = XAB$C_ITM; xab.xab$b_bln = XAB$C_ITMLEN; xab.xab$b_mode = XAB$K_SENSEMODE; xab.xab$l_itemlist = (char *)&items; /* --- initialize XABITMLST itemlist */ dir_flag = 0; items[0].itemcode = XAB$_UCHAR_DIRECTORY; items[0].buflen = 4; items[0].bufadr = &dir_flag; items[0].retlen = 0; items[1].itemcode = 0; items[1].buflen = 0; /* --- open returns the info */ status = sys$open(&fab, 0, 0); if (status & 1) { fab.fab$l_xab = NULL; sys$close (&fab, 0, 0); } printf("!!!!! %s %d\n", filename, dir_flag); return dir_flag; } int main() { printf("DKA600:[NIGEL]LOGIN.COM %d\n", isdir("DKA600:[NIGEL]LOGIN.COM")); printf("DKA600:[NIGEL]VERB.DIR %d\n", isdir("DKA600:[NIGEL]VERB.DIR")); } ===== "OpenVMS is today what Microsoft =============== ===== wants Windows NT v8.0 to be!" (Compaq, 22-Sep-1998) Nigel White mailto:nigel@synergex.com Systems Programmer, Synergex; 2330 Gold Meadow Way; Gold River, CA 95670 Phone: 916/853 0366; http://www.synergex.com spamto: rhundt@fcc.gov jquello@fcc.gov sness@fcc.gov president@whitehouse.gov | Your mouse has moved. Windows NT must be restarted | for the change to take effect. Reboot now ? [ OK ]