mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
res_stir_shaken: refactor utility function
Refactors temp file utility function into file.c. ASTERISK-29809 #close Change-Id: Ife478708c8f2b127239cb73c1755ef18c0bf431b
This commit is contained in:
committed by
Kevin Harwell
parent
39820e3561
commit
1633410161
20
main/file.c
20
main/file.c
@@ -199,6 +199,26 @@ FILE *ast_file_mkftemp(char *template, mode_t mode)
|
||||
return p;
|
||||
}
|
||||
|
||||
int ast_file_fdtemp(const char *path, char **filename, const char *template_name)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (ast_asprintf(filename, "%s/%s", path, template_name) < 0) {
|
||||
ast_log(LOG_ERROR, "Failed to set up temporary file path\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ast_mkdir(path, 0644);
|
||||
|
||||
if ((fd = mkstemp(*filename)) < 0) {
|
||||
ast_log(LOG_NOTICE, "Failed to create temporary file\n");
|
||||
ast_free(*filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int ast_stopstream(struct ast_channel *tmp)
|
||||
{
|
||||
ast_channel_lock(tmp);
|
||||
|
Reference in New Issue
Block a user