summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-11-08 04:57:55 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-11-08 04:57:55 -0600
commit1ab943a4257d53da001fdb797ec67e5097746f9e (patch)
tree204a917db901cb3a299ec90e7cadaf73230cebaf /include
parenta8a8235c6d268a56ff6516d7484b806f8f910791 (diff)
parent70d5f90e3df0968a7a091b5f3c8d7654073de9fd (diff)
Merge "stasis_recording/stored: remove calls to deprecated readdir_r function."
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/file.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/asterisk/file.h b/include/asterisk/file.h
index c71866ead..01e5797f5 100644
--- a/include/asterisk/file.h
+++ b/include/asterisk/file.h
@@ -138,6 +138,34 @@ int ast_filedelete(const char *filename, const char *fmt);
int ast_filecopy(const char *oldname, const char *newname, const char *fmt);
/*!
+ * \brief Callback called for each file found when reading directories
+ * \param dir_name the name of the directory
+ * \param filename the name of the file
+ * \param obj user data object
+ * \return non-zero to stop reading, otherwise zero to continue
+ */
+typedef int (*ast_file_on_file)(const char *dir_name, const char *filename, void *obj);
+
+/*!
+ * \brief Recursively iterate through files and directories up to max_depth
+ * \param dir_name the name of the directory to search
+ * \param on_file callback called on each file
+ * \param obj user data object
+ * \param max_depth re-curse into sub-directories up to a given maximum (-1 = infinite)
+ * \return -1 or errno on failure, otherwise 0
+ */
+int ast_file_read_dirs(const char *dir_name, ast_file_on_file on_file, void *obj, int max_depth);
+
+/*!
+ * \brief Iterate over each file in a given directory
+ * \param dir_name the name of the directory to search
+ * \param on_file callback called on each file
+ * \param obj user data object
+ * \return -1 or errno on failure, otherwise 0
+ */
+#define ast_file_read_dir(dir_name, on_file, obj) ast_file_read_dirs(dir_name, on_file, obj, 1)
+
+/*!
* \brief Waits for a stream to stop or digit to be pressed
* \param c channel to waitstream on
* \param breakon string of DTMF digits to break upon