]> www.fi.muni.cz Git - evince.git/blob - lib/ev-file-helpers.c
Hungarian translation added by "Last-Translator: \n".
[evince.git] / lib / ev-file-helpers.c
1 /*
2  *  Copyright (C) 2002 Jorn Baayen
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2, or (at your option)
7  *  any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  *  $Id$
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <sys/stat.h>
26 #include <glib.h>
27 #include <libgnome/gnome-init.h>
28
29 #include "ev-file-helpers.h"
30
31 static char *dot_dir = NULL;
32
33 static gboolean
34 ensure_dir_exists (const char *dir)
35 {
36         if (g_file_test (dir, G_FILE_TEST_IS_DIR) == FALSE)
37         {
38                 if (g_file_test (dir, G_FILE_TEST_EXISTS) == TRUE)
39                 {
40                         g_warning ("%s exists, please move it out of the way.", dir);
41                         return FALSE;
42                 }
43
44                 if (mkdir (dir, 488) != 0)
45                 {
46                         g_warning ("Failed to create directory %s.", dir);
47                         return FALSE;
48                 }
49         }
50
51         return TRUE;
52 }
53
54 const char *
55 ev_dot_dir (void)
56 {
57         if (dot_dir == NULL)
58         {
59                 gboolean exists;
60
61                 dot_dir = g_build_filename (g_get_home_dir (),
62                                             GNOME_DOT_GNOME,
63                                             "evince",
64                                             NULL);
65
66                 exists = ensure_dir_exists (dot_dir);
67                 g_assert (exists);
68         }
69
70         return dot_dir;
71 }
72
73 void
74 ev_file_helpers_init (void)
75 {
76 }
77
78 void
79 ev_file_helpers_shutdown (void)
80 {
81         g_free (dot_dir);
82         dot_dir = NULL;
83 }