GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-path.c
1 /********************************************************************\
2  * gnc-path.c -- Path lookup of gnucash installation locations *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) 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, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA [email protected] *
20 \********************************************************************/
21 
22 #include "config.h"
23 #include "gnc-path.h"
24 #include "gncla-dir.h"
25 #include <stdio.h>
26 #include "binreloc.h"
27 
28 gchar *gnc_path_get_prefix()
29 {
30  //printf("Returning prefix %s\n", gnc_gbr_find_prefix (PREFIX));
31  return gnc_gbr_find_prefix (PREFIX);
32 }
33 
38 gchar *gnc_path_get_bindir()
39 {
40  //printf("Returning bindir %s\n", gnc_gbr_find_bin_dir (BINDIR));
41  return gnc_gbr_find_bin_dir (BINDIR);
42 }
43 
48 gchar *gnc_path_get_libdir()
49 {
50  //printf("Returning libdir %s\n", gnc_gbr_find_lib_dir (LIBDIR));
51  return gnc_gbr_find_lib_dir (LIBDIR);
52 }
53 
58 gchar *gnc_path_get_pkgdatadir()
59 {
60  gchar *datadir = gnc_gbr_find_data_dir (DATADIR);
61  gchar *result = g_build_filename (datadir, "gnucash", (char*)NULL);
62  g_free (datadir);
63  //printf("Returning pkgdatadir %s\n", result);
64  return result;
65 }
66 
71 gchar *gnc_path_get_pkgdocdir()
72 {
73  gchar *docdir = gnc_gbr_find_data_dir (DATADIR);
74  gchar *result = g_build_filename (docdir, "doc", "gnucash", (char*)NULL);
75  g_free (docdir);
76  //printf("Returning pkgdocdir %s\n", result);
77  return result;
78 }
79 
84 gchar *gnc_path_get_pkgsysconfdir()
85 {
86  gchar *sysconfdir = gnc_gbr_find_etc_dir (SYSCONFDIR);
87  gchar *result = g_build_filename (sysconfdir, "gnucash", (char*)NULL);
88  g_free (sysconfdir);
89  //printf("Returning pkgsysconfdir %s\n", result);
90  return result;
91 }
92 
93 
98 gchar *gnc_path_get_pkglibdir()
99 {
100  gchar *libdir = gnc_path_get_libdir ();
101 #ifdef G_OS_WIN32
102  /* Workaround for Bug 618646, {pkglibdir} will be bin/ on Windows */
103  gchar *result = gnc_gbr_find_bin_dir(libdir);
104 #else
105  gchar *result = g_build_filename (libdir, "gnucash", (char*)NULL);
106 #endif
107  g_free (libdir);
108  //printf("Returning pkglibdir %s\n", result);
109  return result;
110 }
111 
116 gchar *gnc_path_get_gtkbuilderdir()
117 {
118  gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
119  gchar *result = g_build_filename (pkgdatadir, "gtkbuilder", (char*)NULL);
120  g_free (pkgdatadir);
121  //printf("Returning gtkbuilderdir %s\n", result);
122  return result;
123 }
124 
129 gchar *gnc_path_get_localedir()
130 {
131  gchar *prefix = gnc_path_get_prefix();
132  gchar *result = g_build_filename (prefix, LOCALE_DATADIRNAME, "locale", (char*)NULL);
133  g_free (prefix);
134  //printf("Returning localedir %s\n", result);
135  return result;
136 }
137 
142 gchar *gnc_path_get_accountsdir()
143 {
144  gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
145  gchar *result = g_build_filename (pkgdatadir, "accounts", (char*)NULL);
146  g_free (pkgdatadir);
147  //printf("Returning accountsdir %s\n", result);
148  return result;
149 }
150 
155 gchar *gnc_path_get_reportdir()
156 {
157  gchar *result;
158  const gchar *builddir = g_getenv ("GNC_BUILDDIR");
159  if (g_getenv ("GNC_UNINSTALLED") && builddir)
160  {
161  result = g_build_filename (builddir, "src", "report", NULL);
162  }
163  else
164  {
165  /* Careful: if the autoconf macro GNC_SCM_INSTALL_DIR gets changed
166  * in configure.ac, this path should probably change as well.
167  * Currently this code assumes GNC_SCM_INSTALL_DIR is set to
168  * pkgdatadir/scm
169  * We can't use the AC_MACRO GNC_SCM_INSTALL_DIR here directly
170  * because that's expanded at build time. On Windows and OS X
171  * the final path may get installed in a different location
172  * than assumed during build, invalidating the build path at
173  * runtime.
174  */
175  gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
176  result = g_build_filename (pkgdatadir, "scm",
177  "gnucash", "report", (char*)NULL);
178  g_free (pkgdatadir);
179  }
180  //printf("Returning stdreportsdir %s\n", result);
181  return result;
182 }
183 
189 gchar *gnc_path_get_stdreportsdir()
190 {
191  gchar *result;
192  gchar *reportdir = gnc_path_get_reportdir ();
193  if (g_getenv ("GNC_UNINSTALLED"))
194  {
195  result = g_build_filename (reportdir, "standard-reports", "gnucash",
196  "report", "standard-reports", NULL);
197  }
198  else
199  {
200  result = g_build_filename (reportdir, "standard-reports", NULL);
201  }
202  g_free (reportdir);
203  //printf("Returning stdreportsdir %s\n", result);
204  return result;
205 }
206