/*static char *SCCSID = "@(#)dirent.h   6.1 90/11/17";*/
/*      SCCSID = "@(#)dirent.inc  13.6 90/10/02"
 */
/*       IBM/Microsoft Confidential
*
*        Copyright (c) IBM Corporation 1987, 1989
*        Copyright (c) Microsoft Corporation 1987, 1989, 1990
*
*        All Rights Reserved
*
*        Modifications:
*
* 72417  MLM        12/20/95   Copied DIRENT definitions to TKEXPORT.H
*148278  MLM        02/14/96   Conditional around DIRENT definition
*/
/* XLATOFF */
#pragma title("Directory entry")
/* XLATON */

//   This structure was copied to tkexport.h for 72412
//   IT IS ESSENTIAL THAT ANY CHANGES MUST BE COPIED TO TKEXPORT.H
//   The next section will bring in the dir_entry stuff if it
//   hasn't been defined yet.

#ifndef  INCL_TKEXPORT
#define INCL_DIRENT

/*
 *      +-----------------------------+
 *      |  (11 BYTE) filename/ext     |     0       0
 *      +-----------------------------+
 *      |     (BYTE) attributes       |     11      B
 *      +-----------------------------+
 *      |    (8 BYTE) reserved        |     12      C
 *      +-----------------------------+
 *      | (WORD) First cluster of EA  |     20      14
 *      +-----------------------------+
 *      | (WORD) time of last write   |     22      16
 *      +-----------------------------+
 *      | (WORD) date of last write   |     24      18
 *      +-----------------------------+
 *      | (WORD) First cluster of file|     26      1A
 *      +-----------------------------+
 *      |     (DWORD) file size       |     28      1C
 *      +-----------------------------+
 *
 *  First byte of filename  = E5 -> free directory entry
 *                          = 00 -> end of allocated directory
 *  Time:   Bits 0-4=seconds/2, bits 5-10=minute, 11-15=hour
 *  Date:   Bits 0-4=day, bits 5-8=month, bits 9-15=year-1980
 */

typedef struct dir_entry {
uchar_t dir_name[11] ;                  /* file name */
uchar_t dir_attr ;                      /* attribute bits */
uchar_t dir_pad[8] ;                    /* reserved for expansion */
ushort_t dir_EAhandle ;                 /* First cluster of Extended Attributes */
ushort_t dir_time ;                     /* time of last write */
ushort_t dir_date ;                     /* date of last write */
ushort_t dir_firstfile ;                /* first allocation unit of file */
ushort_t dir_size_l ;                   /* low 16 bits of file size */
ushort_t dir_size_h ;                   /* high 16 bits of file size */
} dir_entry ;

#define DIRENT_DELETED 0x0E5            /* indicator of deleted file */
#define DIRENT_NOFEALIST 0              /* Indicates no extended attributes */

/*
  Values for dir_attr

  attr_newfiles is used in the case of IFS to indicate that the type of file
                being requested for findfirst/next is a "new" file i.e. long
                name or a mixed-case name that the FAT FS does not support.
*/

#define attr_read_only 0x1
#define attr_hidden 0x2
#define attr_system 0x4
#define attr_volume_id 0x8
#define attr_directory 0x10
#define attr_archive 0x20
#define attr_device 0x40                /* This is a VERY special bit. */
                                        /*   NO directory entry on a disk EVER */
                                        /*   has this bit set. It is set non-zero */
                                        /*   when a device is found by GETPATH */
#define attr_newfiles 0x40              /* name is non-8.3.  never set for FAT FS */
#define attr_not_norm 0x80              /* do not find normal files in search */

#define attr_all  attr_hidden+attr_system+attr_directory
                                        /* OR of hard attributes for FINDENTRY */

#define attr_ignore  attr_read_only+attr_archive+attr_device
                                        /* ignore these attributes during */
                                        /* search first/next */

#define attr_changeable  attr_read_only+attr_hidden+attr_system+attr_archive
                                        /* changeable via CHMOD */

#define attr_used attr_read_only|attr_hidden|attr_system|attr_volume_id|attr_directory|attr_archive|attr_newfiles
                                        /* We ignore the rest for $Creat due to LOTUS */
                                        /* passing in an attribute of 0x8000!! */

#define attr_not_3xbox    attr_not_norm+attr_newfiles

#define INV_3XBOX_SRCH_ATTRS    attr_newfiles   /* We should not pass this bit */
                                                /* for FSDS from 3xbox.        */

/* Define "must have" attribute bits for FS_FindFirst, per DCR 853. */

#define must_have_attr_read_only        (attr_read_only << 8)
#define must_have_attr_hidden           (attr_hidden << 8)
#define must_have_attr_system           (attr_system << 8)
#define must_have_attr_directory        (attr_directory << 8)
#define must_have_attr_archive          (attr_archive << 8)

#define may_have_all    attr_read_only|attr_hidden|attr_system|attr_directory|attr_archive
#define must_have_all   must_have_attr_read_only|must_have_attr_hidden|must_have_attr_system|must_have_attr_directory|must_have_attr_archive

/* Define "ignore" attribute bit for DosSetPath/FileInfo (DCR 2031) */

#define ignore_attr     0x10000

#endif
