Apache HTTPD
filestat.c
Go to the documentation of this file.
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#define INCL_DOS
18#define INCL_DOSERRORS
19#include "apr_arch_file_io.h"
20#include "apr_file_io.h"
21#include "apr_lib.h"
22#include <sys/time.h>
23#include "apr_strings.h"
24
25
27{
28 finfo->protection = (fstatus->attrFile & FILE_READONLY) ? 0x555 : 0x777;
29
30 if (fstatus->attrFile & FILE_DIRECTORY)
31 finfo->filetype = APR_DIR;
32 else
33 finfo->filetype = APR_REG;
34 /* XXX: No other possible types from FS3? */
35
36 finfo->user = 0;
37 finfo->group = 0;
38 finfo->inode = 0;
39 finfo->device = 0;
40 finfo->size = fstatus->cbFile;
41 finfo->csize = fstatus->cbFileAlloc;
42 apr_os2_time_to_apr_time(&finfo->atime, fstatus->fdateLastAccess,
43 fstatus->ftimeLastAccess );
44 apr_os2_time_to_apr_time(&finfo->mtime, fstatus->fdateLastWrite,
45 fstatus->ftimeLastWrite );
46 apr_os2_time_to_apr_time(&finfo->ctime, fstatus->fdateCreation,
47 fstatus->ftimeCreation );
51}
52
53
54
56{
57 ULONG filetype, fileattr, rc;
58
59 rc = DosQueryHType(file, &filetype, &fileattr);
60
61 if (rc == 0) {
62 switch (filetype & 0xff) {
63 case 0:
64 *ftype = APR_REG;
65 break;
66
67 case 1:
68 *ftype = APR_CHR;
69 break;
70
71 case 2:
72 *ftype = APR_PIPE;
73 break;
74
75 default:
76 /* Brian, is this correct???
77 */
78 *ftype = APR_UNKFILE;
79 break;
80 }
81
82 return APR_SUCCESS;
83 }
84 return APR_FROM_OS_ERROR(rc);
85}
86
87
88
91{
92 ULONG rc;
94
95 if (thefile->isopen) {
96 if (thefile->buffered) {
97 /* XXX: flush here is not mutex protected */
99
100 if (rv != APR_SUCCESS) {
101 return rv;
102 }
103 }
104
106 }
107 else
109
110 if (rc == 0) {
111 FS3_to_finfo(finfo, &fstatus);
112 finfo->fname = thefile->fname;
113
114 if (finfo->filetype == APR_REG) {
115 if (thefile->isopen) {
116 return handle_type(&finfo->filetype, thefile->filedes);
117 }
118 } else {
119 return APR_SUCCESS;
120 }
121 }
122
123 finfo->protection = 0;
124 finfo->filetype = APR_NOFILE;
125 return APR_FROM_OS_ERROR(rc);
126}
127
129{
130 return APR_ENOTIMPL;
131}
132
133
136{
137 ULONG rc;
139
140 finfo->protection = 0;
141 finfo->filetype = APR_NOFILE;
142 finfo->name = NULL;
144
145 if (rc == 0) {
146 FS3_to_finfo(finfo, &fstatus);
147 finfo->fname = fname;
148
149 if (wanted & APR_FINFO_NAME) {
150 ULONG count = 1;
155 &ffb, sizeof(ffb), &count, FIL_STANDARD);
156 if (rc == 0 && count == 1) {
157 finfo->name = apr_pstrdup(cont, ffb.achName);
158 finfo->valid |= APR_FINFO_NAME;
159 }
160 }
161 } else if (rc == ERROR_INVALID_ACCESS) {
162 memset(finfo, 0, sizeof(apr_finfo_t));
164 finfo->protection = 0666;
165 finfo->filetype = APR_CHR;
166
167 if (wanted & APR_FINFO_NAME) {
168 finfo->name = apr_pstrdup(cont, fname);
169 finfo->valid |= APR_FINFO_NAME;
170 }
171 } else {
172 return APR_FROM_OS_ERROR(rc);
173 }
174
175 return (wanted & ~finfo->valid) ? APR_INCOMPLETE : APR_SUCCESS;
176}
177
178
179
184{
186 ULONG rc;
187
188 /* Don't do anything if we can't handle the requested attributes */
191 return APR_SUCCESS;
192
194 if (rc == 0) {
195 ULONG old_attr = fs3.attrFile;
196
198 {
200 fs3.attrFile |= FILE_READONLY;
201 } else {
202 fs3.attrFile &= ~FILE_READONLY;
203 }
204 }
205
207 {
209 fs3.attrFile |= FILE_HIDDEN;
210 } else {
211 fs3.attrFile &= ~FILE_HIDDEN;
212 }
213 }
214
215 if (fs3.attrFile != old_attr) {
216 rc = DosSetPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3), 0);
217 }
218 }
219
220 return APR_FROM_OS_ERROR(rc);
221}
222
223
224/* ### Somebody please write this! */
228{
230 ULONG rc;
232
233 if (rc) {
234 return APR_FROM_OS_ERROR(rc);
235 }
236
237 apr_apr_time_to_os2_time(&fs3.fdateLastWrite, &fs3.ftimeLastWrite, mtime);
238
239 rc = DosSetPathInfo(fname, FIL_STANDARD, &fs3, sizeof(fs3), 0);
240 return APR_FROM_OS_ERROR(rc);
241}
APR File I/O Handling.
APR general purpose library routines.
APR Strings library.
#define APR_INCOMPLETE
Definition apr_errno.h:452
#define APR_ENOTIMPL
Definition apr_errno.h:476
unsigned int count
Definition apr_md5.h:152
apr_redis_t * rc
Definition apr_redis.h:173
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
Definition apr_pools.h:646
apr_size_t size
const char int apr_pool_t * pool
Definition apr_cstr.h:84
#define APR_FROM_OS_ERROR(e)
Definition apr_errno.h:1214
#define APR_SUCCESS
Definition apr_errno.h:225
int apr_status_t
Definition apr_errno.h:44
#define APR_FILE_ATTR_READONLY
#define APR_FILE_ATTR_HIDDEN
apr_int32_t apr_fileperms_t
apr_filetype_e
@ APR_PIPE
@ APR_UNKFILE
@ APR_REG
@ APR_CHR
@ APR_DIR
@ APR_NOFILE
apr_file_t * thefile
apr_uint32_t apr_fileattrs_t
const char apr_fileperms_t perms
apr_fileattrs_t attributes
const char apr_file_t * file
apr_time_t mtime
apr_fileattrs_t apr_fileattrs_t attr_mask
#define APR_FINFO_ATIME
const char apr_int32_t wanted
const char * fname
#define APR_FINFO_NAME
#define APR_FINFO_CTIME
#define APR_FINFO_MTIME
#define APR_FINFO_LINK
#define APR_FINFO_TYPE
#define APR_FINFO_PROT
#define APR_FINFO_SIZE
#define APR_FINFO_CSIZE
apr_pool_t * cont
Definition apr_getopt.h:103
apr_int64_t apr_time_t
Definition apr_time.h:45
return NULL
Definition mod_so.c:359
apr_status_t apr_os2_time_to_apr_time(apr_time_t *result, FDATE os2date, FTIME os2time)
apr_status_t apr_apr_time_to_os2_time(FDATE *os2date, FTIME *os2time, apr_time_t aprtime)
static apr_status_t handle_type(apr_filetype_e *ftype, HFILE file)
Definition filestat.c:55
static void FS3_to_finfo(apr_finfo_t *finfo, FILESTATUS3 *fstatus)
Definition filestat.c:26
apr_gid_t group
apr_filetype_e filetype
const char * name
apr_dev_t device
apr_off_t size
apr_ino_t inode
apr_fileperms_t protection
apr_uid_t user
const char * fname
apr_time_t atime
apr_off_t csize
apr_time_t ctime
apr_time_t mtime
apr_int32_t valid