diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-26 20:34:46 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-26 20:34:46 +0000 |
commit | 2ebf1e8b735cf9874e8a3d0a8ba57ce26cdeeb39 (patch) | |
tree | bf67802aa31b8917cbcd89dce116ab7424370eef /apps/app_record.c | |
parent | 8c8f06edc167c888ae3c999c10c7f7fdea99788c (diff) |
Create directory if it does not exist.
(Closes issue 10061, Reported and patched by eliel)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@71914 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_record.c')
-rw-r--r-- | apps/app_record.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/app_record.c b/apps/app_record.c index fc4bbcd83..b5e85a616 100644 --- a/apps/app_record.c +++ b/apps/app_record.c @@ -81,6 +81,7 @@ static int record_exec(struct ast_channel *chan, void *data) int count = 0; int percentflag = 0; char *filename, *ext = NULL, *silstr, *maxstr, *options; + char *file, *dir; char *vdata, *p; int i = 0; char tmp[256]; @@ -263,8 +264,13 @@ static int record_exec(struct ast_channel *chan, void *data) } ast_dsp_set_threshold(sildet, 256); } - - + + /* Create the directory if it does not exist. */ + dir = ast_strdupa(tmp); + if ((file = strrchr(dir, '/'))) + *file++ = '\0'; + ast_mkdir (dir, 0777); + flags = option_append ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY; s = ast_writefile( tmp, ext, NULL, flags , 0, AST_FILE_MODE); |