1 /*
2  *  DIRUTE.H
3  *  Contributes findfirst, findnext and findclose for POSIX systems.
4  *  Based on code taken from Msged TE. Written by Tobias Ernst.
5  *  Released to the public domain.
6  *  Please note that you must call findclose!!! So it is a good idea
7  *  to also include this file on non-Unix systems, because in this
8  *  case, it provides a dummy findclose.
9  */
10 
11 #ifndef __DIRUTE_H__
12 #define __DIRUTE_H__
13 
14 #include "platform.h"
15 
16 #ifndef UNIX
17 #ifndef OS_2
18 #define findclose(x) (x)
19 #define FA_CASE 0
20 #include <dir.h>
21 #endif
22 #define adaptcase file_exists
23 #else
24 
25 #include <unistd.h>
26 #include <dirent.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <ctype.h>
30 
31 
32 #include <stdio.h>             /* FILENAME_MAX */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 struct ffblk
39 {
40         /* public data */
41         long           ff_fsize;
42         unsigned long  ff_attrib;
43         unsigned short ff_ftime;
44         unsigned short ff_fdate;
45         char           ff_name[FILENAME_MAX + 1];
46 
47         /* private data */
48         DIR           *dir;
49         struct dirent *de;
50         int            attribute_mask;
51         char           firstbit[FILENAME_MAX + 1];
52         char           lastbit [FILENAME_MAX + 1];
53         char           fullname[FILENAME_MAX + 1];
54 };
55 
56 #define FA_RDONLY  1  /* also find files that are read only         */
57 #define FA_ARCH    0  /* also find "archived" files (dummy!)        */
58 #define FA_HIDDEN  4  /* also find hidden (dotted) files            */
59 #define FA_SYSTEM  4  /* also find "system" files (dummy!)          */
60 #define FA_DIREC   8  /* also find subdirectories                   */
61 #define FA_CASE   16  /* enforce case sensitivity on Unix (without  */
62                       /* this flag, the search is case INSENSITIVE) */
63 
64 int findfirst (const char *, struct ffblk*, int);
65 int findnext  (struct ffblk*);
66 int findclose (struct ffblk*);
67 int adaptcase (char *);
68 
69 #ifdef __cplusplus
70 }  /* end of extern "C" */
71 #endif
72 
73 #endif /* UNIX     */
74 
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 int file_exists(char *);
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* dirute.h */
85 
86 
87