| | @@ -904,10 +904,168 @@ |
| 904 | 904 | */ |
| 905 | 905 | #define SQLITE_EXTENSION_INIT1 |
| 906 | 906 | #define SQLITE_EXTENSION_INIT2(X) (void)(X) |
| 907 | 907 | |
| 908 | 908 | #if defined(_WIN32) && defined(_MSC_VER) |
| 909 | +/************************* Begin test_windirent.h ******************/ |
| 910 | +/* |
| 911 | +** 2015 November 30 |
| 912 | +** |
| 913 | +** The author disclaims copyright to this source code. In place of |
| 914 | +** a legal notice, here is a blessing: |
| 915 | +** |
| 916 | +** May you do good and not evil. |
| 917 | +** May you find forgiveness for yourself and forgive others. |
| 918 | +** May you share freely, never taking more than you give. |
| 919 | +** |
| 920 | +************************************************************************* |
| 921 | +** This file contains declarations for most of the opendir() family of |
| 922 | +** POSIX functions on Win32 using the MSVCRT. |
| 923 | +*/ |
| 924 | + |
| 925 | +#if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H) |
| 926 | +#define SQLITE_WINDIRENT_H |
| 927 | + |
| 928 | +/* |
| 929 | +** We need several data types from the Windows SDK header. |
| 930 | +*/ |
| 931 | + |
| 932 | +#define WIN32_LEAN_AND_MEAN |
| 933 | +#include "windows.h" |
| 934 | + |
| 935 | +/* |
| 936 | +** We need several support functions from the SQLite core. |
| 937 | +*/ |
| 938 | + |
| 939 | + |
| 940 | +/* |
| 941 | +** We need several things from the ANSI and MSVCRT headers. |
| 942 | +*/ |
| 943 | + |
| 944 | +#include <stdio.h> |
| 945 | +#include <stdlib.h> |
| 946 | +#include <errno.h> |
| 947 | +#include <io.h> |
| 948 | +#include <limits.h> |
| 949 | +#include <sys/types.h> |
| 950 | +#include <sys/stat.h> |
| 951 | + |
| 952 | +/* |
| 953 | +** We may need several defines that should have been in "sys/stat.h". |
| 954 | +*/ |
| 955 | + |
| 956 | +#ifndef S_ISREG |
| 957 | +#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) |
| 958 | +#endif |
| 959 | + |
| 960 | +#ifndef S_ISDIR |
| 961 | +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) |
| 962 | +#endif |
| 963 | + |
| 964 | +#ifndef S_ISLNK |
| 965 | +#define S_ISLNK(mode) (0) |
| 966 | +#endif |
| 967 | + |
| 968 | +/* |
| 969 | +** We may need to provide the "mode_t" type. |
| 970 | +*/ |
| 971 | + |
| 972 | +#ifndef MODE_T_DEFINED |
| 973 | + #define MODE_T_DEFINED |
| 974 | + typedef unsigned short mode_t; |
| 975 | +#endif |
| 976 | + |
| 977 | +/* |
| 978 | +** We may need to provide the "ino_t" type. |
| 979 | +*/ |
| 980 | + |
| 981 | +#ifndef INO_T_DEFINED |
| 982 | + #define INO_T_DEFINED |
| 983 | + typedef unsigned short ino_t; |
| 984 | +#endif |
| 985 | + |
| 986 | +/* |
| 987 | +** We need to define "NAME_MAX" if it was not present in "limits.h". |
| 988 | +*/ |
| 989 | + |
| 990 | +#ifndef NAME_MAX |
| 991 | +# ifdef FILENAME_MAX |
| 992 | +# define NAME_MAX (FILENAME_MAX) |
| 993 | +# else |
| 994 | +# define NAME_MAX (260) |
| 995 | +# endif |
| 996 | +#endif |
| 997 | + |
| 998 | +/* |
| 999 | +** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T". |
| 1000 | +*/ |
| 1001 | + |
| 1002 | +#ifndef NULL_INTPTR_T |
| 1003 | +# define NULL_INTPTR_T ((intptr_t)(0)) |
| 1004 | +#endif |
| 1005 | + |
| 1006 | +#ifndef BAD_INTPTR_T |
| 1007 | +# define BAD_INTPTR_T ((intptr_t)(-1)) |
| 1008 | +#endif |
| 1009 | + |
| 1010 | +/* |
| 1011 | +** We need to provide the necessary structures and related types. |
| 1012 | +*/ |
| 1013 | + |
| 1014 | +#ifndef DIRENT_DEFINED |
| 1015 | +#define DIRENT_DEFINED |
| 1016 | +typedef struct DIRENT DIRENT; |
| 1017 | +typedef DIRENT *LPDIRENT; |
| 1018 | +struct DIRENT { |
| 1019 | + ino_t d_ino; /* Sequence number, do not use. */ |
| 1020 | + unsigned d_attributes; /* Win32 file attributes. */ |
| 1021 | + char d_name[NAME_MAX + 1]; /* Name within the directory. */ |
| 1022 | +}; |
| 1023 | +#endif |
| 1024 | + |
| 1025 | +#ifndef DIR_DEFINED |
| 1026 | +#define DIR_DEFINED |
| 1027 | +typedef struct DIR DIR; |
| 1028 | +typedef DIR *LPDIR; |
| 1029 | +struct DIR { |
| 1030 | + intptr_t d_handle; /* Value returned by "_findfirst". */ |
| 1031 | + DIRENT d_first; /* DIRENT constructed based on "_findfirst". */ |
| 1032 | + DIRENT d_next; /* DIRENT constructed based on "_findnext". */ |
| 1033 | +}; |
| 1034 | +#endif |
| 1035 | + |
| 1036 | +/* |
| 1037 | +** Provide a macro, for use by the implementation, to determine if a |
| 1038 | +** particular directory entry should be skipped over when searching for |
| 1039 | +** the next directory entry that should be returned by the readdir() or |
| 1040 | +** readdir_r() functions. |
| 1041 | +*/ |
| 1042 | + |
| 1043 | +#ifndef is_filtered |
| 1044 | +# define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM)) |
| 1045 | +#endif |
| 1046 | + |
| 1047 | +/* |
| 1048 | +** Provide the function prototype for the POSIX compatiable getenv() |
| 1049 | +** function. This function is not thread-safe. |
| 1050 | +*/ |
| 1051 | + |
| 1052 | +extern const char *windirent_getenv(const char *name); |
| 1053 | + |
| 1054 | +/* |
| 1055 | +** Finally, we can provide the function prototypes for the opendir(), |
| 1056 | +** readdir(), readdir_r(), and closedir() POSIX functions. |
| 1057 | +*/ |
| 1058 | + |
| 1059 | +extern LPDIR opendir(const char *dirname); |
| 1060 | +extern LPDIRENT readdir(LPDIR dirp); |
| 1061 | +extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result); |
| 1062 | +extern INT closedir(LPDIR dirp); |
| 1063 | + |
| 1064 | +#endif /* defined(WIN32) && defined(_MSC_VER) */ |
| 1065 | + |
| 1066 | +/************************* End test_windirent.h ********************/ |
| 909 | 1067 | /************************* Begin test_windirent.c ******************/ |
| 910 | 1068 | /* |
| 911 | 1069 | ** 2015 November 30 |
| 912 | 1070 | ** |
| 913 | 1071 | ** The author disclaims copyright to this source code. In place of |
| | @@ -921,12 +1079,11 @@ |
| 921 | 1079 | ** This file contains code to implement most of the opendir() family of |
| 922 | 1080 | ** POSIX functions on Win32 using the MSVCRT. |
| 923 | 1081 | */ |
| 924 | 1082 | |
| 925 | 1083 | #if defined(_WIN32) && defined(_MSC_VER) |
| 926 | | - |
| 927 | | -#include "test_windirent.h" |
| 1084 | +/* #include "test_windirent.h" */ |
| 928 | 1085 | |
| 929 | 1086 | /* |
| 930 | 1087 | ** Implementation of the POSIX getenv() function using the Win32 API. |
| 931 | 1088 | ** This function is not thread-safe. |
| 932 | 1089 | */ |
| | @@ -1909,11 +2066,11 @@ |
| 1909 | 2066 | # include <utime.h> |
| 1910 | 2067 | #else |
| 1911 | 2068 | # include "windows.h" |
| 1912 | 2069 | # include <io.h> |
| 1913 | 2070 | # include <direct.h> |
| 1914 | | -# include "test_windirent.h" |
| 2071 | +/* # include "test_windirent.h" */ |
| 1915 | 2072 | # define dirent DIRENT |
| 1916 | 2073 | # define timespec TIMESPEC |
| 1917 | 2074 | # define stat _stat |
| 1918 | 2075 | # define mkdir(path,mode) _mkdir(path) |
| 1919 | 2076 | # define lstat(path,buf) _stat(path,buf) |
| 1920 | 2077 | |