apr_pool_t *pool = params->pool;
dav_error *err = NULL;
int isdir = fsctx->res1.collection;
+ apr_finfo_t dirent;
apr_dir_t *dirp;
/* ensure the context is prepared properly, then call the func */
/* ### need a better error */
return dav_new_error(pool, HTTP_NOT_FOUND, 0, NULL);
}
- while ((apr_readdir(dirp)) == APR_SUCCESS) {
- const char *name;
+ while ((apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp)) == APR_SUCCESS) {
apr_size_t len;
- apr_get_dir_filename(&name, dirp);
- len = strlen(name);
+ len = strlen(dirent.name);
/* avoid recursing into our current, parent, or state directories */
- if (name[0] == '.' && (len == 1 || (name[1] == '.' && len == 2))) {
+ if (dirent.name[0] == '.'
+ && (len == 1 || (dirent.name[1] == '.' && len == 2))) {
continue;
}
/* ### example: .htaccess is normally configured to fail auth */
/* stuff in the state directory is never authorized! */
- if (!strcmp(name, DAV_FS_STATE_DIR)) {
+ if (!strcmp(dirent.name, DAV_FS_STATE_DIR)) {
continue;
}
}
/* skip the state dir unless a HIDDEN is performed */
if (!(params->walk_type & DAV_WALKTYPE_HIDDEN)
- && !strcmp(name, DAV_FS_STATE_DIR)) {
+ && !strcmp(dirent.name, DAV_FS_STATE_DIR)) {
continue;
}
/* append this file onto the path buffer (copy null term) */
- dav_buffer_place_mem(pool, &fsctx->path1, name, len + 1, 0);
+ dav_buffer_place_mem(pool, &fsctx->path1, dirent.name, len + 1, 0);
+
+ /* ### Optimize me, dirent can give us what we need! */
if (apr_lstat(&fsctx->info1.finfo, fsctx->path1.buf,
APR_FINFO_NORM, pool) != APR_SUCCESS) {
/* woah! where'd it go? */
/* copy the file to the URI, too. NOTE: we will pad an extra byte
for the trailing slash later. */
- dav_buffer_place_mem(pool, &fsctx->uri_buf, name, len + 1, 1);
+ dav_buffer_place_mem(pool, &fsctx->uri_buf, dirent.name, len + 1, 1);
/* if there is a secondary path, then do that, too */
if (fsctx->path2.buf != NULL) {
- dav_buffer_place_mem(pool, &fsctx->path2, name, len + 1, 0);
+ dav_buffer_place_mem(pool, &fsctx->path2, dirent.name, len + 1, 0);
}
/* set up the (internal) pathnames for the two resources */
}
/* ### check the return value of this? */
- apr_closedir(dirp);
+ apr_dir_close(dirp);
if (err != NULL)
return err;
char *title_name = ap_escape_html(r->pool, r->uri);
char *title_endp;
char *name = r->filename;
-
- apr_dir_t *d;
+ apr_finfo_t dirent;
+ apr_dir_t *thedir;
apr_status_t status;
int num_ent = 0, x;
struct ent *head, *p;
char keyid;
char direction;
- if ((status = apr_dir_open(&d, name, r->pool)) != APR_SUCCESS) {
+ if ((status = apr_dir_open(&thedir, name, r->pool)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
"Can't open directory for index: %s", r->filename);
return HTTP_FORBIDDEN;
ap_send_http_header(r);
if (r->header_only) {
- apr_closedir(d);
+ apr_dir_close(thedir);
return 0;
}
* linked list and then arrayificate them so qsort can use them.
*/
head = NULL;
- while (apr_readdir(d) == APR_SUCCESS) {
- const char *d_name;
- apr_get_dir_filename(&d_name, d);
- p = make_autoindex_entry(d_name, autoindex_opts,
+ while (apr_dir_read(&dirent, APR_FINFO_DIRENT, thedir) == APR_SUCCESS) {
+ p = make_autoindex_entry(dirent.name, autoindex_opts,
autoindex_conf, r, keyid, direction);
if (p != NULL) {
p->next = head;
}
output_directories(ar, num_ent, autoindex_conf, r, autoindex_opts, keyid,
direction);
- apr_closedir(d);
+ apr_dir_close(thedir);
if (autoindex_opts & FANCY_INDEXING) {
ap_rputs("<HR>\n", r);
char *filp;
int prefix_len;
apr_dir_t *dirp;
+ apr_finfo_t dirent;
apr_status_t status;
struct var_rec mime_info;
struct accept_rec accept_info;
return HTTP_FORBIDDEN;
}
- while (apr_readdir(dirp) == APR_SUCCESS) {
+ while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
request_rec *sub_req;
- const char *d_name;
-
- apr_get_dir_filename(&d_name, dirp);
+
/* Do we have a match? */
-
- if (strncmp(d_name, filp, prefix_len)) {
+ if (strncmp(dirent.name, filp, prefix_len)) {
continue;
}
- if (d_name[prefix_len] != '.') {
+ if (dirent.name[prefix_len] != '.') {
continue;
}
* which we'll be slapping default_type on later).
*/
- sub_req = ap_sub_req_lookup_file(d_name, r, NULL);
+ sub_req = ap_sub_req_lookup_file(dirent.name, r, NULL);
/* If it has a handler, we'll pretend it's a CGI script,
* since that's a good indication of the sort of thing it
((sub_req->handler) &&
!strcmp(sub_req->handler, "type-map"))) {
- apr_closedir(dirp);
+ apr_dir_close(dirp);
neg->avail_vars->nelts = 0;
if (sub_req->status != HTTP_OK) {
return sub_req->status;
/* Have reasonable variant --- gather notes. */
mime_info.sub_req = sub_req;
- mime_info.file_name = apr_pstrdup(neg->pool, d_name);
+ mime_info.file_name = apr_pstrdup(neg->pool, dirent.name);
if (sub_req->content_encoding) {
mime_info.content_encoding = sub_req->content_encoding;
}
clean_var_rec(&mime_info);
}
- apr_closedir(dirp);
+ apr_dir_close(dirp);
set_vlist_validator(r, r);
{
spconfig *cfg;
char *good, *bad, *postgood, *url;
- const char *fname;
+ apr_finfo_t dirent;
int filoc, dotloc, urlen, pglen;
apr_array_header_t *candidates = NULL;
apr_dir_t *dir;
dotloc = strlen(bad);
}
- while (apr_readdir(dir) == APR_SUCCESS &&
- apr_get_dir_filename(&fname, dir) == APR_SUCCESS) {
+ while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dir) == APR_SUCCESS) {
sp_reason q;
/*
* requested one, we must have found a broken symlink or some such.
* Do _not_ try to redirect this, it causes a loop!
*/
- if (strcmp(bad, fname) == 0) {
- apr_closedir(dir);
+ if (strcmp(bad, dirent.name) == 0) {
+ apr_dir_close(dir);
return OK;
}
* miscapitalization errors are checked first (like, e.g., lower case
* file, upper case request)
*/
- else if (strcasecmp(bad, fname) == 0) {
+ else if (strcasecmp(bad, dirent.name) == 0) {
misspelled_file *sp_new;
sp_new = (misspelled_file *) apr_push_array(candidates);
- sp_new->name = apr_pstrdup(r->pool, fname);
+ sp_new->name = apr_pstrdup(r->pool, dirent.name);
sp_new->quality = SP_MISCAPITALIZED;
}
* simple typing errors are checked next (like, e.g.,
* missing/extra/transposed char)
*/
- else if ((q = spdist(bad, fname)) != SP_VERYDIFFERENT) {
+ else if ((q = spdist(bad, dirent.name)) != SP_VERYDIFFERENT) {
misspelled_file *sp_new;
sp_new = (misspelled_file *) apr_push_array(candidates);
- sp_new->name = apr_pstrdup(r->pool, fname);
+ sp_new->name = apr_pstrdup(r->pool, dirent.name);
sp_new->quality = q;
}
* (e.g. foo.gif and foo.html) This code will pick the first one
* it finds. Better than a Not Found, though.
*/
- int entloc = ap_ind(fname, '.');
+ int entloc = ap_ind(dirent.name, '.');
if (entloc == -1) {
- entloc = strlen(fname);
+ entloc = strlen(dirent.name);
}
if ((dotloc == entloc)
- && !strncasecmp(bad, fname, dotloc)) {
+ && !strncasecmp(bad, dirent.name, dotloc)) {
misspelled_file *sp_new;
sp_new = (misspelled_file *) apr_push_array(candidates);
- sp_new->name = apr_pstrdup(r->pool, fname);
+ sp_new->name = apr_pstrdup(r->pool, dirent.name);
sp_new->quality = SP_VERYDIFFERENT;
}
#endif
}
}
- apr_closedir(dir);
+ apr_dir_close(dir);
if (candidates->nelts != 0) {
/* Wow... we found us a mispelling. Construct a fixed url */
*/
if (ap_is_rdirectory(ptemp, fname)) {
apr_dir_t *dirp;
+ apr_finfo_t dirent;
int current;
apr_array_header_t *candidates = NULL;
fnames *fnew;
exit(1);
}
candidates = apr_make_array(p, 1, sizeof(fnames));
- while (apr_readdir(dirp) == APR_SUCCESS) {
- const char *d_name;
- apr_get_dir_filename(&d_name, dirp);
- /* strip out '.' and '..' */
- if (strcmp(d_name, ".") &&
- strcmp(d_name, "..")) {
+ while (apr_dir_read(&dirent, APR_FINFO_DIRENT, dirp) == APR_SUCCESS) {
+ /* strip out '.' and '..' */
+ if (strcmp(dirent.name, ".") &&
+ strcmp(dirent.name, "..")) {
fnew = (fnames *) apr_push_array(candidates);
- fnew->fname = ap_make_full_path(p, fname, d_name);
+ fnew->fname = ap_make_full_path(p, fname, dirent.name);
}
}
- apr_closedir(dirp);
+ apr_dir_close(dirp);
if (candidates->nelts != 0) {
qsort((void *) candidates->elts, candidates->nelts,
sizeof(fnames), fname_alphasort);