wrowe 01/01/24 08:16:37
Modified: file_io/unix dir.c
Log:
The last patch to unix/filestat.c added the APR_INCOMPLETE. This patch
teaches apr_dir_read to respect that result and return it itself.
Proposed by: Greg Stein
Revision Changes Path
1.48 +18 -3 apr/file_io/unix/dir.c
Index: dir.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/dir.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- dir.c 2001/01/23 22:09:53 1.47
+++ dir.c 2001/01/24 16:16:35 1.48
@@ -147,8 +147,10 @@
return ret;
}
- /* What we already know */
- /* XXX: Optimize here with d_fileno, d_type etc by platform */
+ /* What we already know - and restrict the wanted test below to stat
+ * only if stat will give us what this platform supports, and we can't
+ * get it from the platform.
+ * XXX: Optimize here with d_fileno, d_type etc by platform */
wanted &= ~(APR_FINFO_NAME);
if (wanted)
{
@@ -161,16 +163,29 @@
apr_cpystrn(fspec + off, thedir->entry->d_name, sizeof(fspec) - off);
/* ??? Or lstat below? What is it we really want? */
ret = apr_stat(finfo, fspec, wanted, thedir->cntxt);
+ }
+
+ if (wanted && (ret == APR_SUCCESS || ret == APR_INCOMPLETE)) {
+ wanted &= ~finfo->valid;
+ ret = APR_SUCCESS;
}
- if (!wanted || ret) {
+ else {
+ /* We don't bail because we fail to stat, when we are only -required-
+ * to readdir... but the result will be APR_INCOMPLETE
+ */
finfo->cntxt = thedir->cntxt;
finfo->valid = 0;
}
+
/* We passed a stack name that is now gone */
finfo->fname = NULL;
finfo->valid |= APR_FINFO_NAME;
/* XXX: Optimize here with d_fileno, d_type etc by platform */
finfo->name = thedir->entry->d_name;
+
+ if (wanted)
+ return APR_INCOMPLETE;
+
return APR_SUCCESS;
}