Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/ev-file-helpers.c83
-rw-r--r--lib/ev-file-helpers.h36
3 files changed, 121 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9a3bd51..6bcfc2e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -12,4 +12,6 @@ noinst_LTLIBRARIES = libev.la
libev_la_SOURCES= \
ev-debug.c \
ev-debug.h \
+ ev-file-helpers.c \
+ ev-file-helpers.h \
$(NULL)
diff --git a/lib/ev-file-helpers.c b/lib/ev-file-helpers.c
new file mode 100644
index 0000000..d9daf6a
--- /dev/null
+++ b/lib/ev-file-helpers.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2002 Jorn Baayen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/stat.h>
+#include <glib.h>
+#include <libgnome/gnome-init.h>
+
+#include "ev-file-helpers.h"
+
+static char *dot_dir = NULL;
+
+static gboolean
+ensure_dir_exists (const char *dir)
+{
+ if (g_file_test (dir, G_FILE_TEST_IS_DIR) == FALSE)
+ {
+ if (g_file_test (dir, G_FILE_TEST_EXISTS) == TRUE)
+ {
+ g_warning ("%s exists, please move it out of the way.", dir);
+ return FALSE;
+ }
+
+ if (mkdir (dir, 488) != 0)
+ {
+ g_warning ("Failed to create directory %s.", dir);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+const char *
+ev_dot_dir (void)
+{
+ if (dot_dir == NULL)
+ {
+ gboolean exists;
+
+ dot_dir = g_build_filename (g_get_home_dir (),
+ GNOME_DOT_GNOME,
+ "evince",
+ NULL);
+
+ exists = ensure_dir_exists (dot_dir);
+ g_assert (exists);
+ }
+
+ return dot_dir;
+}
+
+void
+ev_file_helpers_init (void)
+{
+}
+
+void
+ev_file_helpers_shutdown (void)
+{
+ g_free (dot_dir);
+ dot_dir = NULL;
+}
diff --git a/lib/ev-file-helpers.h b/lib/ev-file-helpers.h
new file mode 100644
index 0000000..43dc75c
--- /dev/null
+++ b/lib/ev-file-helpers.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2002 Jorn Baayen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_FILE_HELPERS_H
+#define EPHY_FILE_HELPERS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+const char *ev_dot_dir (void);
+
+void ev_file_helpers_init (void);
+
+void ev_file_helpers_shutdown (void);
+
+G_END_DECLS
+
+#endif /* EPHY_FILE_HELPERS_H */