Statistics
| Branch: | Tag: | Revision:

root / lib / filter-utils.c @ aebfd4cc

History | View | Annotate | Download (965 Bytes)

1
/* SylFilter - a message filter
2
 *
3
 * Copyright (C) 2011 Hiroyuki Yamamoto
4
 * Copyright (C) 2011 Sylpheed Development Team
5
 */
6
7
#include <glib.h>
8
9
#include "libsylph/utils.h"
10
11
#include "filter-utils.h"
12
13
char *xfilter_utils_get_file_contents(const char *file)
14
{
15
        char *contents = NULL;
16
17
        g_return_val_if_fail(file != NULL, NULL);
18
19
        if (g_file_get_contents(file, &contents, NULL, NULL))
20
                return contents;
21
        else
22
                return NULL;
23
}
24
25
void xfilter_free_mem(void *mem)
26
{
27
        g_free(mem);
28
}
29
30
const char *xfilter_utils_get_home_dir(void)
31
{
32
        return get_home_dir();
33
}
34
35
const char *xfilter_utils_get_base_dir(void)
36
{
37
        return get_rc_dir();
38
}
39
40
int xfilter_utils_set_base_dir(const char *path)
41
{
42
        const char *tmpdir;
43
44
        if (xfilter_utils_mkdir(path) < 0)
45
                return -1;
46
47
        set_rc_dir(path);
48
        tmpdir = get_tmp_dir();
49
        if (tmpdir)
50
                xfilter_utils_mkdir(tmpdir);
51
52
        return 0;
53
}
54
55
int xfilter_utils_mkdir(const char *path)
56
{
57
        if (is_dir_exist(path))
58
                return 0;
59
60
        return g_mkdir(path, 0700);
61
}