Changeset 56


Ignore:
Timestamp:
Aug 7, 2007, 6:56:58 AM (18 years ago)
Author:
Paul Smedley
Message:

Add new function os2_isattribute to check file attributes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/samba/source/lib/os2ea.c

    r12 r56  
    2020#include <malloc.h>
    2121
     22/* these define the attribute byte as seen by DOS */
     23#define aRONLY (1L<<0)          /* 0x01 */
     24#define aHIDDEN (1L<<1)         /* 0x02 */
     25#define aSYSTEM (1L<<2)         /* 0x04 */
     26#define aVOLID (1L<<3)          /* 0x08 */
     27#define aDIR (1L<<4)            /* 0x10 */
     28#define aARCH (1L<<5)           /* 0x20 */
     29
    2230#ifndef TESTING
    2331#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
     
    6169        }
    6270        return 0;
     71}
     72
     73int os2_isattribute(char *path, unsigned short attr)
     74{
     75    HDIR          hdirFindHandle = HDIR_CREATE;
     76    FILEFINDBUF3  FindBuffer     = {0};      /* Returned from FindFirst/Next */
     77    USHORT        dosattr;                      /* attribute to search for */
     78    ULONG         ulResultBufLen = sizeof(FILEFINDBUF3);
     79    ULONG         ulFindCount    = 1;        /* Look for 1 file at a time    */
     80    APIRET        rc             = NO_ERROR; /* Return code                  */
     81    if (attr==aARCH)
     82                        dosattr=MUST_HAVE_ARCHIVED;
     83    else if (attr==aRONLY)
     84                        dosattr=MUST_HAVE_READONLY;
     85    else if (attr==aSYSTEM)
     86                        dosattr=MUST_HAVE_SYSTEM;
     87    else if (attr==aHIDDEN)
     88                        dosattr=MUST_HAVE_HIDDEN;
     89
     90    rc = DosFindFirst( path,                /* File pattern - all files     */
     91                       &hdirFindHandle,      /* Directory search handle      */
     92                        dosattr,
     93                       &FindBuffer,          /* Result buffer                */
     94                       ulResultBufLen,       /* Result buffer length         */
     95                       &ulFindCount,         /* Number of entries to find    */
     96                       FIL_STANDARD);        /* Return Level 1 file info     */
     97
     98   if (rc != NO_ERROR) {
     99         rc = DosFindClose(hdirFindHandle);    /* Close our directory handle */
     100       return 1;
     101
     102    } else {
     103         rc = DosFindClose(hdirFindHandle);    /* Close our directory handle */
     104        return 0;
     105
     106    } /* endif */
     107
    63108}
    64109
Note: See TracChangeset for help on using the changeset viewer.