1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "apr_private.h"
22 #include "apr_general.h"
23 #include "apr_tables.h"
24 #include "apr_file_io.h"
25 #include "apr_file_info.h"
26 #include "apr_errno.h"
29 /* System headers the file I/O library needs */
33 #if APR_HAVE_SYS_TYPES_H
34 #include <sys/types.h>
42 #if APR_HAVE_STRINGS_H
48 #ifdef HAVE_SYS_STAT_H
60 #if APR_HAVE_SYS_UIO_H
63 #if APR_HAVE_SYS_TIME_H
69 /* End System headers */
71 #define APR_FILE_BUFSIZE 4096
80 apr_interval_time_t timeout;
82 enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
83 int ungetchar; /* Last char provided by an unget op. (-1 = no char)*/
85 /* Stuff for buffered mode */
87 int bufpos; /* Read/Write position in buffer */
88 unsigned long dataRead; /* amount of valid data read into buffer */
89 int direction; /* buffer being used for 0 = read, 1 = write */
90 unsigned long filePtr; /* position in file of handle */
92 struct apr_thread_mutex_t *thlock;
97 #define file_lock(f) do { \
99 apr_thread_mutex_lock((f)->thlock); \
101 #define file_unlock(f) do { \
103 apr_thread_mutex_unlock((f)->thlock); \
106 #define file_lock(f) do {} while (0)
107 #define file_unlock(f) do {} while (0)
114 struct dirent *entry;
117 typedef struct apr_stat_entry_t apr_stat_entry_t;
119 struct apr_stat_entry_t {
126 #define MAX_SERVER_NAME 64
127 #define MAX_VOLUME_NAME 64
128 #define MAX_PATH_NAME 256
129 #define MAX_FILE_NAME 256
133 /* If the user passes d: vs. D: (or //mach/share vs. //MACH/SHARE),
134 * we need to fold the case to canonical form. This function is
137 apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p);
139 /* This function check to see of the given path includes a drive/volume
140 * specifier. If the _only_ parameter is set to DRIVE_ONLY then it
141 * check to see of the path only contains a drive/volume specifier and
144 apr_status_t filepath_has_drive(const char *rootpath, int only, apr_pool_t *p);
146 /* This function compares the drive/volume specifiers for each given path.
147 * It returns zero if they match or non-zero if not.
149 apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p);
151 apr_status_t apr_unix_file_cleanup(void *);
152 apr_status_t apr_unix_child_file_cleanup(void *);
154 apr_status_t apr_file_flush_locked(apr_file_t *thefile);
155 apr_status_t apr_file_info_get_locked(apr_finfo_t *finfo, apr_int32_t wanted,
156 apr_file_t *thefile);
158 #endif /* ! FILE_IO_H */