summaryrefslogtreecommitdiff
path: root/src/core/rawlog.c
diff options
context:
space:
mode:
authorJari Matilainen <jari.matilainen@gmail.com>2015-09-24 11:59:18 +0200
committerJari Matilainen <jari.matilainen@gmail.com>2015-09-24 11:59:18 +0200
commita2277e84bd390b9eaca906541f32e5d60e529f7f (patch)
treec5e556326b65df9fa9fa17abdf315f8257957e2d /src/core/rawlog.c
parentfc3c0a84205885e5914c7e0812b35a4acbabc3b0 (diff)
downloadirssi-a2277e84bd390b9eaca906541f32e5d60e529f7f.zip
Added functionality to create dir if dir specified in rawlog filename
Diffstat (limited to 'src/core/rawlog.c')
-rw-r--r--src/core/rawlog.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/core/rawlog.c b/src/core/rawlog.c
index 2fa6b850..875c0ef2 100644
--- a/src/core/rawlog.c
+++ b/src/core/rawlog.c
@@ -32,6 +32,7 @@
static int rawlog_lines;
static int signal_rawlog;
static int log_file_create_mode;
+static int log_dir_create_mode;
RAWLOG_REC *rawlog_create(void)
{
@@ -145,9 +146,13 @@ void rawlog_close(RAWLOG_REC *rawlog)
void rawlog_save(RAWLOG_REC *rawlog, const char *fname)
{
- char *path;
+ char *path, *dir;
int f;
+ dir = g_path_get_dirname(fname);
+ mkpath(dir, log_dir_create_mode);
+ g_free(dir);
+
path = convert_home(fname);
f = open(path, O_WRONLY | O_APPEND | O_CREAT, log_file_create_mode);
g_free(path);
@@ -165,6 +170,11 @@ static void read_settings(void)
{
rawlog_set_size(settings_get_int("rawlog_lines"));
log_file_create_mode = octal2dec(settings_get_int("log_create_mode"));
+ log_dir_create_mode = log_file_create_mode;
+ if (log_file_create_mode & 0400) log_dir_create_mode |= 0100;
+ if (log_file_create_mode & 0040) log_dir_create_mode |= 0010;
+ if (log_file_create_mode & 0004) log_dir_create_mode |= 0001;
+
}
static void cmd_rawlog(const char *data, SERVER_REC *server, void *item)