00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef FILE_IO_H
00018 #define FILE_IO_H
00019
00020 #include "apr.h"
00021 #include "apr_private.h"
00022 #include "apr_pools.h"
00023 #include "apr_general.h"
00024 #include "apr_tables.h"
00025 #include "apr_thread_mutex.h"
00026 #include "apr_file_io.h"
00027 #include "apr_file_info.h"
00028 #include "apr_errno.h"
00029 #include "apr_arch_misc.h"
00030 #include "apr_poll.h"
00031
00032 #ifdef HAVE_SYS_STAT_H
00033 #include <sys/stat.h>
00034 #endif
00035 #if APR_HAVE_SYS_TYPES_H
00036 #include <sys/types.h>
00037 #endif
00038 #ifdef HAVE_SYS_FCNTL_H
00039 #include <fcntl.h>
00040 #endif
00041 #ifdef HAVE_TIME_H
00042 #include <time.h>
00043 #endif
00044 #if APR_HAVE_DIRENT_H
00045 #include <dirent.h>
00046 #endif
00047 #ifdef HAVE_MALLOC_H
00048 #include <malloc.h>
00049 #endif
00050
00051 #if APR_HAS_UNICODE_FS
00052 #include "arch/win32/apr_arch_utf8.h"
00053 #include <wchar.h>
00054
00055 typedef apr_uint16_t apr_wchar_t;
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 apr_status_t utf8_to_unicode_path(apr_wchar_t* dststr, apr_size_t dstchars,
00070 const char* srcstr);
00071 apr_status_t unicode_to_utf8_path(char* dststr, apr_size_t dstchars,
00072 const apr_wchar_t* srcstr);
00073
00074 #endif
00075
00076
00077
00078
00079
00080
00081
00082
00083 void *res_name_from_filename(const char *file, int global, apr_pool_t *pool);
00084
00085 #define APR_FILE_MAX MAX_PATH
00086
00087 #define APR_FILE_BUFSIZE 4096
00088
00089
00090 #ifdef _MSC_VER
00091 #define S_IFIFO _S_IFIFO
00092 #define S_IFBLK 0060000
00093 #define S_IFLNK 0120000
00094 #define S_IFSOCK 0140000
00095 #define S_IFWHT 0160000
00096 #endif
00097
00098
00099 #define APR_OPENINFO 0x00100000
00100 #define APR_OPENLINK 0x00200000
00101 #define APR_READCONTROL 0x00400000
00102 #define APR_WRITECONTROL 0x00800000
00103 #define APR_WRITEATTRS 0x01000000
00104
00105
00106
00107 #ifndef FILE_ATTRIBUTE_DEVICE
00108 #define FILE_ATTRIBUTE_DEVICE 0x00000040
00109 #endif
00110 #ifndef FILE_ATTRIBUTE_REPARSE_POINT
00111 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
00112 #endif
00113 #ifndef FILE_FLAG_OPEN_NO_RECALL
00114 #define FILE_FLAG_OPEN_NO_RECALL 0x00100000
00115 #endif
00116 #ifndef FILE_FLAG_OPEN_REPARSE_POINT
00117 #define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000
00118 #endif
00119 #ifndef TRUSTEE_IS_WELL_KNOWN_GROUP
00120 #define TRUSTEE_IS_WELL_KNOWN_GROUP 5
00121 #endif
00122
00123
00124 #define APR_FINFO_WIN32_DIR (APR_FINFO_NAME | APR_FINFO_TYPE \
00125 | APR_FINFO_CTIME | APR_FINFO_ATIME \
00126 | APR_FINFO_MTIME | APR_FINFO_SIZE)
00127
00128
00129 #define APR_FREADONLY 0x10000000
00130
00131
00132 int fillin_fileinfo(apr_finfo_t *finfo, WIN32_FILE_ATTRIBUTE_DATA *wininfo,
00133 int byhandle, apr_int32_t wanted);
00134
00135
00136 apr_status_t more_finfo(apr_finfo_t *finfo, const void *ufile,
00137 apr_int32_t wanted, int whatfile);
00138
00139
00140 #define MORE_OF_HANDLE 0
00141 #define MORE_OF_FSPEC 1
00142 #define MORE_OF_WFSPEC 2
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 #define filedes filehand
00155
00156 struct apr_file_t {
00157 apr_pool_t *pool;
00158 HANDLE filehand;
00159 BOOLEAN pipe;
00160 OVERLAPPED *pOverlapped;
00161 apr_interval_time_t timeout;
00162 apr_int32_t flags;
00163
00164
00165 apr_finfo_t *finfo;
00166 char *fname;
00167 DWORD dwFileAttributes;
00168 int eof_hit;
00169 BOOLEAN buffered;
00170 int ungetchar;
00171 int append;
00172
00173
00174 char *buffer;
00175 apr_size_t bufpos;
00176 apr_size_t dataRead;
00177 int direction;
00178 apr_off_t filePtr;
00179 apr_thread_mutex_t *mutex;
00180
00181
00182 apr_pollset_t *pollset;
00183
00184
00185 };
00186
00187 struct apr_dir_t {
00188 apr_pool_t *pool;
00189 HANDLE dirhand;
00190 apr_size_t rootlen;
00191 char *dirname;
00192 char *name;
00193 union {
00194 #if APR_HAS_UNICODE_FS
00195 struct {
00196 WIN32_FIND_DATAW *entry;
00197 } w;
00198 #endif
00199 #if APR_HAS_ANSI_FS
00200 struct {
00201 WIN32_FIND_DATAA *entry;
00202 } n;
00203 #endif
00204 };
00205 int bof;
00206 };
00207
00208
00209
00210
00211
00212 extern const char apr_c_is_fnchar[256];
00213
00214 #define IS_FNCHAR(c) (apr_c_is_fnchar[(unsigned char)(c)] & 1)
00215 #define IS_SHCHAR(c) ((apr_c_is_fnchar[(unsigned char)(c)] & 2) == 2)
00216
00217
00218
00219
00220
00221
00222
00223 apr_status_t filepath_root_test(char *path, apr_pool_t *p);
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 apr_status_t filepath_drive_get(char **rootpath, char drive,
00237 apr_int32_t flags, apr_pool_t *p);
00238
00239
00240
00241
00242
00243
00244 apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p);
00245
00246
00247 apr_status_t file_cleanup(void *);
00248
00269 apr_status_t apr_create_nt_pipe(apr_file_t **in, apr_file_t **out,
00270 apr_int32_t blocking_mode,
00271 apr_pool_t *p);
00272
00274 #define APR_READ_BLOCK 3
00275
00276 #define APR_WRITE_BLOCK 4
00277
00278 #endif