r22788 - gnucash/trunk/src/core-utils - Fix code to find html files

Geert Janssens gjanssens at code.gnucash.org
Wed Feb 20 13:50:21 EST 2013


Author: gjanssens
Date: 2013-02-20 13:50:21 -0500 (Wed, 20 Feb 2013)
New Revision: 22788
Trac: http://svn.gnucash.org/trac/changeset/22788

Modified:
   gnucash/trunk/src/core-utils/gnc-filepath-utils.c
Log:
Fix code to find html files

- look in pkg_data_dir as last resort (eg /usr/share/gnucash)
- effectively test all directories instead of only the second one
- add a debug print line

Modified: gnucash/trunk/src/core-utils/gnc-filepath-utils.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-filepath-utils.c	2013-02-20 18:50:10 UTC (rev 22787)
+++ gnucash/trunk/src/core-utils/gnc-filepath-utils.c	2013-02-20 18:50:21 UTC (rev 22788)
@@ -45,13 +45,17 @@
 
 #include "gnc-path.h"
 #include "gnc-filepath-utils.h"
+#include "libqof/qof/qof.h"
 
 #ifdef _MSC_VER
 #include <glib/gwin32.h>
 #define PATH_MAX MAXPATHLEN
 #endif
 
+/* This static indicates the debugging module that this .o belongs to.  */
+static QofLogModule log_module = G_LOG_DOMAIN;
 
+
 /**
  * Scrubs a filename by changing "strange" chars (e.g. those that are not
  * valid in a win32 file name) to "_".
@@ -177,6 +181,8 @@
  *   (typically $HOME/.gnucash/html)
  * - the gnucash documentation directory
  *   (typically /usr/share/doc/gnucash)
+ * - the gnucash data directory
+ *   (typically /usr/share/gnucash)
  * It searches in this order.
  *
  * This is used by gnc_path_find_localized_file to search for
@@ -192,6 +198,7 @@
         {
             gnc_build_dotgnucash_path ("html"),
             gnc_path_get_pkgdocdir (),
+            gnc_path_get_pkgdatadir (),
             NULL
         };
     gchar **dirs;
@@ -207,7 +214,8 @@
 
     for (i = 0; dirs[i]; i++)
     {
-        full_path = g_build_filename (dirs[1], file_name, (gchar *)NULL);
+        full_path = g_build_filename (dirs[i], file_name, (gchar *)NULL);
+        DEBUG ("Checking for existence of %s", full_path);
         full_path = check_path_return_if_valid (full_path);
         if (full_path != NULL)
             return full_path;
@@ -238,6 +246,8 @@
  *      (e.g. $HOME/.gnucash/html)
  *  \li the gnucash documentation directory
  *      (e.g. /usr/share/doc/gnucash/)
+ *  \li last resort option: the gnucash data directory
+ *      (e.g. /usr/share/gnucash/)
  *
  *  The paths are searched for in that order. If a matching file is
  *  found, return the absolute path to it.
@@ -278,8 +288,8 @@
     /* If not found in a localized directory, try to find the file
      * in any of the base directories
      */
-    full_path = gnc_path_find_localized_html_file_internal (file_name);
-    return full_path;
+    return gnc_path_find_localized_html_file_internal (file_name);
+
 }
 
 /* ====================================================================== */



More information about the gnucash-changes mailing list