summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2019-06-25 14:21:56 +0000
committerJoe Orton <jorton@apache.org>2019-06-25 14:21:56 +0000
commit864ce9d1b1784c31386a7a5ff568e78f56a0a75f (patch)
tree75ac7cea477231ea31a07f15b37a47a6cd5e010b /include
parente0f71494adc916c15fca5038ac1e45b77113168c (diff)
downloadapr-864ce9d1b1784c31386a7a5ff568e78f56a0a75f.tar.gz
Add apr_dir_pread(), a variant of apr_dir_read() which allows callers
to read a directory with constant memory consumption: * include/apr_file_info.h: Add warning on memory consumption for apr_dir_read; declare apr_dir_pread. * file_io/unix/dir.c (apr_dir_pread): Rename from apr_dir_read and take pool argument. (apr_dir_read): Reimplement using it. * file_io/win32/dir.c, file_io/os2/dir.c: Likewise, but untested. * test/testdir.c (test_pread) [APR_POOL_DEBUG]: Add test case. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1862071 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r--include/apr_file_info.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/apr_file_info.h b/include/apr_file_info.h
index cfddc68da..f08762cea 100644
--- a/include/apr_file_info.h
+++ b/include/apr_file_info.h
@@ -263,11 +263,33 @@ APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir);
* not be filled in, and you need to check the @c finfo->valid bitmask
* to verify that what you're looking for is there. When no more
* entries are available, APR_ENOENT is returned.
+ *
+ * @warning Memory will be allocated in the pool passed to apr_dir_open;
+ * use apr_dir_pread() and a temporary pool to restrict memory
+ * consumption for a large directory.
*/
APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted,
apr_dir_t *thedir);
/**
+ * Read the next entry from the specified directory.
+ * @param finfo the file info structure and filled in by apr_dir_read
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_
+ values
+ * @param thedir the directory descriptor returned from apr_dir_open
+ * @param pool the pool to use for allocations
+ * @remark No ordering is guaranteed for the entries read.
+ *
+ * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may
+ * not be filled in, and you need to check the @c finfo->valid bitmask
+ * to verify that what you're looking for is there. When no more
+ * entries are available, APR_ENOENT is returned.
+ */
+APR_DECLARE(apr_status_t) apr_dir_pread(apr_finfo_t *finfo, apr_int32_t wanted,
+ apr_dir_t *thedir, apr_pool_t *pool);
+
+
+/**
* Rewind the directory to the first entry.
* @param thedir the directory descriptor to rewind.
*/