Skip to content

Commit

Permalink
Fix code to find html files
Browse files Browse the repository at this point in the history
- 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

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22788 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
gjanssens committed Feb 20, 2013
1 parent 9d5daf7 commit 6776fc0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core-utils/gnc-filepath-utils.c
Expand Up @@ -45,12 +45,16 @@

#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
Expand Down Expand Up @@ -177,6 +181,8 @@ gnc_resolve_file_path (const gchar * filefrag)
* (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
Expand All @@ -192,6 +198,7 @@ gnc_path_find_localized_html_file_internal (const gchar * file_name)
{
gnc_build_dotgnucash_path ("html"),
gnc_path_get_pkgdocdir (),
gnc_path_get_pkgdatadir (),
NULL
};
gchar **dirs;
Expand All @@ -207,7 +214,8 @@ gnc_path_find_localized_html_file_internal (const gchar * file_name)

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;
Expand Down Expand Up @@ -238,6 +246,8 @@ gnc_path_find_localized_html_file_internal (const gchar * file_name)
* (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.
Expand Down Expand Up @@ -278,8 +288,8 @@ gnc_path_find_localized_html_file (const gchar *file_name)
/* 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);

}

/* ====================================================================== */
Expand Down

0 comments on commit 6776fc0

Please sign in to comment.