              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 262.3     Problem in converting a directory with DCL convert         3 of 4
EPS::VANDENHEUVEL "Hein"                             97 lines  11-MAR-1997 10:27
--------------------------------------------------------------------------------
    
    You can NOT use the Convert utility to manipulate directories.
    Trust me, I've been there, I've done that, and while it may
    appear to work on some directories, it will break on others.
    
    The directory file format is _very_ close to a normal sequential
    file with variable length record and non-block-spanning attribute
    but is NOT exactly the same. The specific differences are in the
    the 0xFFFF end-of-block marker handling.
    
>However, after the conversion, the file test1.dir is not a directory file.
    
    	The FDL file does NOT take the directory attribute into account.
    	This is a specific 'UCHAR' bit that SET FILE/NODIR can switch OFF
    	but there is no build in command to switch it ON. I'll include a
    	little C program to switch the bit on in case you like to play
    	with fire and can not find your matches.
    
    Have fun,
    		Hein.
    
#include atrdef
#include fibdef
#include fchdef
#include iodef
#include rms
#include stdio
#include stdlib
#include string

main(argc,argv)
int argc;
char *argv[];
    {
    int status, channel, uchar;
    struct FAB fab;
    struct NAM nam;
    short iosb[4];
    struct { long count; long address; } fibdes;
    struct fibdef fib;
    struct atrdef atr[2];
    char usage[] = "Usage: $ SET_DIR filename\n";

    if (argc != 2) printf("%s",&usage), exit(1);

    fab = cc$rms_fab;
    fab.fab$l_fna = argv[1];
    fab.fab$b_fns = strlen(fab.fab$l_fna);
    fab.fab$l_dna = ".DIR;1";
    fab.fab$b_dns = strlen(fab.fab$l_dna);
    fab.fab$b_fac = FAB$M_GET | FAB$M_PUT;
    fab.fab$l_fop = FAB$M_UFO;
    fab.fab$b_org = FAB$C_SEQ;	/* ebk and ffb are only valid for seq files */
    fab.fab$l_nam = &nam;

    nam = cc$rms_nam;

    status=sys$open(&fab);
    if (!(status & 1)) lib$stop(status);
    channel = fab.fab$l_stv;

    fibdes.count = sizeof(fib);
    fibdes.address = &fib;

    fib.fib$r_acctl_overlay.fib$l_acctl  = ( FIB$M_WRITE );
    fib.fib$r_fid_overlay.fib$r_fid_fields.fib$w_fid_num =
	nam.nam$w_fid[0];
    fib.fib$r_fid_overlay.fib$r_fid_fields.fib$w_fid_seq =
	nam.nam$w_fid[1];
    fib.fib$r_fid_overlay.fib$r_fid_fields.fib$r_fid_rvn_overlay.fib$w_fid_rvn =
	nam.nam$w_fid[2];

    atr[0].atr$w_type  = ATR$C_UCHAR;
    atr[0].atr$w_size  = ATR$S_UCHAR;
    atr[0].atr$l_addr  = &uchar;
    atr[1].atr$w_type  = 0;
    atr[1].atr$w_size  = 0;

/*  Get the file's current uchar */

    status = SYS$QIOW(0,channel,IO$_ACCESS,iosb,0,0,&fibdes,0,0,0,&atr,0);
    if (status & 1) status = iosb[0];
    if (!(status & 1)) lib$stop(status);

/*  Set the new uchar */

    uchar |= FCH$M_DIRECTORY;

    status = SYS$QIOW(0,channel,IO$_MODIFY,iosb,0,0,&fibdes,0,0,0,&atr,0);
    if (status & 1) status = iosb[0];
    if (!(status & 1)) lib$stop(status);

/*  Release the file */

    status = SYS$QIOW(0,channel,IO$_DEACCESS,iosb,0,0,&fibdes,0,0,0,0,0);

    }
