Moved function to get log dir to log.c

This commit is contained in:
James Booth
2013-02-02 22:18:08 +00:00
parent 0b4c464919
commit c58aca5640
4 changed files with 33 additions and 35 deletions

View File

@@ -32,10 +32,10 @@
#include <ncurses.h>
#endif
#include "preferences.h"
#include "common.h"
#include "files.h"
#include "log.h"
#include "preferences.h"
#include "tools/autocomplete.h"
static gchar *prefs_loc;
@@ -45,6 +45,7 @@ gint log_maxsize = 0;
static Autocomplete boolean_choice_ac;
static void _save_prefs(void);
static gchar * _get_preferences_file(void);
void
prefs_load(void)
@@ -52,7 +53,7 @@ prefs_load(void)
GError *err;
log_info("Loading preferences");
prefs_loc = files_get_preferences_file();
prefs_loc = _get_preferences_file();
prefs = g_key_file_new();
g_key_file_load_from_file(prefs, prefs_loc, G_KEY_FILE_KEEP_COMMENTS,
@@ -453,3 +454,16 @@ _save_prefs(void)
char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
g_file_set_contents(prefs_loc, g_prefs_data, g_data_size, NULL);
}
static gchar *
_get_preferences_file(void)
{
gchar *xdg_config = xdg_get_config_home();
GString *prefs_file = g_string_new(xdg_config);
g_string_append(prefs_file, "/profanity/profrc");
gchar *result = strdup(prefs_file->str);
g_free(xdg_config);
g_string_free(prefs_file, TRUE);
return result;
}