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.
21 #include <string.h> /* strlen() */
29 dia_get_data_directory (const gchar
* subdir
)
33 * Calulate from executable path
35 gchar sLoc
[MAX_PATH
+1];
36 HINSTANCE hInst
= GetModuleHandle(NULL
);
38 if (0 != GetModuleFileName(hInst
, sLoc
, MAX_PATH
))
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
);
50 if (strlen (subdir
) == 0)
51 return g_strconcat (DATADIR
, NULL
);
53 return g_strconcat (DATADIR
, G_DIR_SEPARATOR_S
, subdir
, NULL
);
59 dia_get_lib_directory (const gchar
* subdir
)
63 * Calulate from executable path
65 gchar sLoc
[MAX_PATH
+1];
66 HINSTANCE hInst
= GetModuleHandle(NULL
);
68 if (0 != GetModuleFileName(hInst
, sLoc
, MAX_PATH
))
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
);
80 return g_strconcat (LIBDIR
, G_DIR_SEPARATOR_S
, subdir
, NULL
);
85 dia_config_filename(const gchar
*subfile
)
89 homedir
= g_get_home_dir();
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
,