From f0bf734e6e1a2f32e3f31e45690d4cb9fabdef6f Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sun, 24 Jun 2007 20:37:41 +0000 Subject: [PATCH] change the directory walking functions to pass it the buffer. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5458 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_apr.h | 2 +- src/switch_apr.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index 2c8aa703cd..8ed7c98621 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -744,7 +744,7 @@ typedef struct switch_dir switch_dir_t; SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir); -SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir); +SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len); /** @} */ diff --git a/src/switch_apr.c b/src/switch_apr.c index 06c6f62624..5648185816 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -402,18 +402,19 @@ SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir) return apr_dir_close(thedir->dir_handle); } -SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir) +SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len) { const char *fname = NULL; apr_int32_t finfo_flags = APR_FINFO_DIRENT | APR_FINFO_TYPE | APR_FINFO_NAME; while (apr_dir_read(&(thedir->finfo), finfo_flags, thedir->dir_handle) == SWITCH_STATUS_SUCCESS) { if (thedir->finfo.filetype != APR_REG) continue; - fname = thedir->finfo.fname; - if (!fname) - fname = thedir->finfo.name; - if (!fname) + if (thedir->finfo.fname) { + switch_copy_string(buf, thedir->finfo.fname, len); + fname = buf; + } else { continue; + } } return fname; }