re-adding .pngs as binary
[dia.git] / lib / dia_dirs.c
blobb49a398532b75a2d520bd38b2cd236949ce315e5
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
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 of the License, or
7 * (at your option) any later version.
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.
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.
19 #include <config.h>
21 #include <string.h> /* strlen() */
23 #include "dia_dirs.h"
24 #ifdef G_OS_WIN32
25 #include <windows.h>
26 #endif
28 gchar*
29 dia_get_data_directory (const gchar* subdir)
31 #ifdef G_OS_WIN32
33 * Calulate from executable path
35 gchar sLoc [MAX_PATH+1];
36 HINSTANCE hInst = GetModuleHandle(NULL);
38 if (0 != GetModuleFileName(hInst, sLoc, MAX_PATH))
40 /* strip the name */
41 if (strrchr(sLoc, G_DIR_SEPARATOR))
42 strrchr(sLoc, G_DIR_SEPARATOR)[0] = 0;
43 /* and one dir (bin) */
44 if (strrchr(sLoc, G_DIR_SEPARATOR))
45 strrchr(sLoc, G_DIR_SEPARATOR)[1] = 0;
47 return g_strconcat (sLoc , subdir, NULL);
49 #else
50 if (strlen (subdir) == 0)
51 return g_strconcat (DATADIR, NULL);
52 else
53 return g_strconcat (DATADIR, G_DIR_SEPARATOR_S, subdir, NULL);
54 #endif
58 gchar*
59 dia_get_lib_directory (const gchar* subdir)
61 #ifdef G_OS_WIN32
63 * Calulate from executable path
65 gchar sLoc [MAX_PATH+1];
66 HINSTANCE hInst = GetModuleHandle(NULL);
68 if (0 != GetModuleFileName(hInst, sLoc, MAX_PATH))
70 /* strip the name */
71 if (strrchr(sLoc, G_DIR_SEPARATOR))
72 strrchr(sLoc, G_DIR_SEPARATOR)[0] = 0;
73 /* and one dir (bin) */
74 if (strrchr(sLoc, G_DIR_SEPARATOR))
75 strrchr(sLoc, G_DIR_SEPARATOR)[1] = 0;
77 return g_strconcat (sLoc , subdir, NULL);
79 #else
80 return g_strconcat (LIBDIR, G_DIR_SEPARATOR_S, subdir, NULL);
81 #endif
84 gchar *
85 dia_config_filename(const gchar *subfile)
87 gchar *homedir;
89 homedir = g_get_home_dir();
90 if (!homedir) {
91 homedir = g_get_tmp_dir(); /* put config stuff in /tmp -- not ideal, but
92 * we should not reach this state */
94 return g_strconcat(homedir, G_DIR_SEPARATOR_S ".dia" G_DIR_SEPARATOR_S,
95 subfile, NULL);