add files_file_in_account_data_path()
As all parts of the code invoking the `files_get_account_data_path()` function did the same afterwards, a function has been added with the same behavior. 1. create path 2. `mkdir` of that path 3. return final path Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "common.h"
|
||||
@@ -191,6 +193,25 @@ files_get_account_data_path(const char* const specific_dir, const char* const ji
|
||||
return result;
|
||||
}
|
||||
|
||||
gchar*
|
||||
files_file_in_account_data_path(const char* const specific_dir, const char* const jid, const char* const file_name)
|
||||
{
|
||||
gchar* data_path = files_get_account_data_path(specific_dir, jid);
|
||||
|
||||
if (g_mkdir_with_parents(data_path, S_IRWXU) != 0) {
|
||||
log_error("Failed to create directory at '%s' with error '%s'", data_path, strerror(errno));
|
||||
g_free(data_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!file_name) {
|
||||
return data_path;
|
||||
}
|
||||
gchar* filename = g_strdup_printf("%s/%s", data_path, file_name);
|
||||
g_free(data_path);
|
||||
return filename;
|
||||
}
|
||||
|
||||
static char*
|
||||
_files_get_xdg_config_home(void)
|
||||
{
|
||||
|
||||
@@ -69,4 +69,7 @@ gchar* files_get_account_data_path(const char* const specific_dir, const char* c
|
||||
gchar* files_get_log_file(const char* const log_file);
|
||||
gchar* files_get_inputrc_file(void);
|
||||
|
||||
gchar*
|
||||
files_file_in_account_data_path(const char* const specific_dir, const char* const jid, const char* const file_name);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user