mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
some quick apr_dir wrappers.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5083 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
606b469551
commit
55cf8326db
@ -739,6 +739,12 @@ SWITCH_DECLARE(switch_size_t) switch_file_get_size(switch_file_t *thefile);
|
|||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_memory_pool_t *pool);
|
SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_memory_pool_t *pool);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -373,6 +373,42 @@ SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename, switch_
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct switch_dir {
|
||||||
|
apr_dir_t *dir_handle;
|
||||||
|
apr_finfo_t finfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool)
|
||||||
|
{
|
||||||
|
switch_status_t status;
|
||||||
|
switch_dir_t *dir = switch_core_alloc(pool, sizeof(switch_dir_t));
|
||||||
|
status = apr_dir_open(&(dir->dir_handle), dirname, pool);
|
||||||
|
*new_dir = dir;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return fname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* thread stubs */
|
/* thread stubs */
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user