OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ** 2015 November 30 |
| 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: |
| 6 ** |
| 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. |
| 10 ** |
| 11 ************************************************************************* |
| 12 ** This file contains declarations for most of the opendir() family of |
| 13 ** POSIX functions on Win32 using the MSVCRT. |
| 14 */ |
| 15 |
| 16 #if defined(_WIN32) && defined(_MSC_VER) |
| 17 |
| 18 /* |
| 19 ** We need several data types from the Windows SDK header. |
| 20 */ |
| 21 |
| 22 #define WIN32_LEAN_AND_MEAN |
| 23 #include "windows.h" |
| 24 |
| 25 /* |
| 26 ** We need several support functions from the SQLite core. |
| 27 */ |
| 28 |
| 29 #include "sqlite3.h" |
| 30 |
| 31 /* |
| 32 ** We need several things from the ANSI and MSVCRT headers. |
| 33 */ |
| 34 |
| 35 #include <stdio.h> |
| 36 #include <stdlib.h> |
| 37 #include <errno.h> |
| 38 #include <io.h> |
| 39 #include <limits.h> |
| 40 |
| 41 /* |
| 42 ** We may need to provide the "ino_t" type. |
| 43 */ |
| 44 |
| 45 #ifndef INO_T_DEFINED |
| 46 #define INO_T_DEFINED |
| 47 typedef unsigned short ino_t; |
| 48 #endif |
| 49 |
| 50 /* |
| 51 ** We need to define "NAME_MAX" if it was not present in "limits.h". |
| 52 */ |
| 53 |
| 54 #ifndef NAME_MAX |
| 55 # ifdef FILENAME_MAX |
| 56 # define NAME_MAX (FILENAME_MAX) |
| 57 # else |
| 58 # define NAME_MAX (260) |
| 59 # endif |
| 60 #endif |
| 61 |
| 62 /* |
| 63 ** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T". |
| 64 */ |
| 65 |
| 66 #ifndef NULL_INTPTR_T |
| 67 # define NULL_INTPTR_T ((intptr_t)(0)) |
| 68 #endif |
| 69 |
| 70 #ifndef BAD_INTPTR_T |
| 71 # define BAD_INTPTR_T ((intptr_t)(-1)) |
| 72 #endif |
| 73 |
| 74 /* |
| 75 ** We need to provide the necessary structures and related types. |
| 76 */ |
| 77 |
| 78 typedef struct DIRENT DIRENT; |
| 79 typedef struct DIR DIR; |
| 80 typedef DIRENT *LPDIRENT; |
| 81 typedef DIR *LPDIR; |
| 82 |
| 83 struct DIRENT { |
| 84 ino_t d_ino; /* Sequence number, do not use. */ |
| 85 unsigned d_attributes; /* Win32 file attributes. */ |
| 86 char d_name[NAME_MAX + 1]; /* Name within the directory. */ |
| 87 }; |
| 88 |
| 89 struct DIR { |
| 90 intptr_t d_handle; /* Value returned by "_findfirst". */ |
| 91 DIRENT d_first; /* DIRENT constructed based on "_findfirst". */ |
| 92 DIRENT d_next; /* DIRENT constructed based on "_findnext". */ |
| 93 }; |
| 94 |
| 95 /* |
| 96 ** Provide a macro, for use by the implementation, to determine if a |
| 97 ** particular directory entry should be skipped over when searching for |
| 98 ** the next directory entry that should be returned by the readdir() or |
| 99 ** readdir_r() functions. |
| 100 */ |
| 101 |
| 102 #ifndef is_filtered |
| 103 # define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM)) |
| 104 #endif |
| 105 |
| 106 /* |
| 107 ** Provide the function prototype for the POSIX compatiable getenv() |
| 108 ** function. This function is not thread-safe. |
| 109 */ |
| 110 |
| 111 extern const char *windirent_getenv(const char *name); |
| 112 |
| 113 /* |
| 114 ** Finally, we can provide the function prototypes for the opendir(), |
| 115 ** readdir(), readdir_r(), and closedir() POSIX functions. |
| 116 */ |
| 117 |
| 118 extern LPDIR opendir(const char *dirname); |
| 119 extern LPDIRENT readdir(LPDIR dirp); |
| 120 extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result); |
| 121 extern INT closedir(LPDIR dirp); |
| 122 |
| 123 #endif /* defined(WIN32) && defined(_MSC_VER) */ |
OLD | NEW |