Apache HTTPD
dir.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#include "apr_arch_file_io.h"
18#include "apr_file_io.h"
19#include "apr_lib.h"
20#include "apr_strings.h"
21#include "apr_portable.h"
22#include <string.h>
23
25{
27 return apr_dir_close(dir);
28}
29
30
31
51
52
53
55{
56 int rv = 0;
57
58 if (thedir->handle) {
60
61 if (rv == 0) {
62 thedir->handle = 0;
63 }
64 }
65
66 return APR_FROM_OS_ERROR(rv);
67}
68
69
70
73{
74 int rv;
75 ULONG entries = 1;
76
77 if (thedir->handle == 0) {
81 &thedir->entry, sizeof(thedir->entry), &entries, FIL_STANDARD);
82 } else {
83 rv = DosFindNext(thedir->handle, &thedir->entry, sizeof(thedir->entry), &entries);
84 }
85
86 finfo->pool = thedir->pool;
87 finfo->fname = NULL;
88 finfo->valid = 0;
89
90 if (rv == 0 && entries == 1) {
92
93 /* We passed a name off the stack that has popped */
94 finfo->fname = NULL;
95 finfo->size = thedir->entry.cbFile;
96 finfo->csize = thedir->entry.cbFileAlloc;
97
98 /* Only directories & regular files show up in directory listings */
99 finfo->filetype = (thedir->entry.attrFile & FILE_DIRECTORY) ? APR_DIR : APR_REG;
100
101 apr_os2_time_to_apr_time(&finfo->mtime, thedir->entry.fdateLastWrite,
102 thedir->entry.ftimeLastWrite);
103 apr_os2_time_to_apr_time(&finfo->atime, thedir->entry.fdateLastAccess,
104 thedir->entry.ftimeLastAccess);
105 apr_os2_time_to_apr_time(&finfo->ctime, thedir->entry.fdateCreation,
106 thedir->entry.ftimeCreation);
107
108 finfo->name = thedir->entry.achName;
112
113 return APR_SUCCESS;
114 }
115
117
118 if (rv)
119 return APR_FROM_OS_ERROR(rv);
120
121 return APR_ENOENT;
122}
123
124
125
127{
128 return apr_dir_close(thedir);
129}
130
131
132
134{
136}
137
138
139
141{
143}
144
145
146
148{
149 if (dir == NULL) {
150 return APR_ENODIR;
151 }
152 *thedir = &dir->handle;
153 return APR_SUCCESS;
154}
155
156
157
160{
161 if ((*dir) == NULL) {
162 (*dir) = (apr_dir_t *)apr_pcalloc(pool, sizeof(apr_dir_t));
163 (*dir)->pool = pool;
164 }
165 (*dir)->handle = *thedir;
166 return APR_SUCCESS;
167}
#define TRUE
Definition abts.h:38
#define FALSE
Definition abts.h:35
APR File I/O Handling.
APR general purpose library routines.
APR Portability Routines.
APR Strings library.
request_rec int int apr_table_t const char * path
#define APR_ENOMEM
Definition apr_errno.h:683
#define APR_ENODIR
Definition apr_errno.h:301
#define APR_ENOENT
Definition apr_errno.h:662
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
const char * dirname
apr_int32_t apr_dir_t * thedir
#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
apr_int32_t apr_fileperms_t
@ APR_REG
@ APR_DIR
const char apr_int32_t apr_fileperms_t perm
#define APR_FINFO_ATIME
const char apr_int32_t wanted
#define APR_FINFO_NAME
#define APR_FINFO_CTIME
#define APR_FINFO_MTIME
#define APR_FINFO_TYPE
#define APR_FINFO_SIZE
#define APR_FINFO_CSIZE
#define apr_pcalloc(p, size)
Definition apr_pools.h:465
DIR apr_os_dir_t
apr_dir_t * dir
return NULL
Definition mod_so.c:359
apr_status_t apr_os2_time_to_apr_time(apr_time_t *result, FDATE os2date, FTIME os2time)
static apr_status_t dir_cleanup(void *thedir)
Definition dir.c:24
struct dirent * entry
apr_pool_t * pool
apr_filetype_e filetype
const char * name
apr_off_t size
apr_pool_t * pool
const char * fname
apr_time_t atime
apr_off_t csize
apr_time_t ctime
apr_time_t mtime
apr_int32_t valid
apr_status_t apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, apr_dir_t *thedir)
Definition dir.c:142
apr_status_t apr_dir_make(const char *path, apr_fileperms_t perm, apr_pool_t *pool)
Definition dir.c:297
apr_status_t apr_dir_remove(const char *path, apr_pool_t *pool)
Definition dir.c:343
apr_status_t apr_dir_close(apr_dir_t *thedir)
Definition dir.c:109
apr_status_t apr_dir_open(apr_dir_t **new, const char *dirname, apr_pool_t *pool)
Definition dir.c:75
apr_status_t apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir)
Definition dir.c:353
apr_status_t apr_dir_rewind(apr_dir_t *thedir)
Definition dir.c:291
apr_status_t apr_os_dir_put(apr_dir_t **dir, apr_os_dir_t *thedir, apr_pool_t *pool)
Definition dir.c:362