Eliminate *-vicinity functions from e-guile reports.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19563 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2010-09-08 07:14:05 +00:00
parent 071c442ec5
commit 025f3dd92c
8 changed files with 74 additions and 45 deletions

View File

@ -4,6 +4,7 @@
#include <gnc-glib-utils.h>
#include <gnc-main.h>
#include <gnc-path.h>
#include <gnc-filepath-utils.h>
#include <glib.h>
SCM scm_init_sw_core_utils_module (void);
@ -17,6 +18,9 @@ gchar * g_find_program_in_path(const gchar *);
gboolean gnc_is_debugging(void);
gchar * gnc_path_get_stdreportsdir(void);
gchar * gnc_build_dotgnucash_path(const gchar *);
gchar * gnc_build_report_path(const gchar *);
gchar * gnc_build_stdreports_path(const gchar *);
void gnc_scm_log_warn(const gchar *);
void gnc_scm_log_error(const gchar *);

View File

@ -11,6 +11,9 @@
(re-export gnc-is-debugging)
(re-export gnc-path-get-stdreportsdir)
(re-export gnc-build-dotgnucash-path)
(re-export gnc-build-report-path)
(re-export gnc-build-stdreports-path)
(re-export g-find-program-in-path)
(re-export gnc-utf8?)
(re-export gnc-utf8-strip-invalid-strdup)

View File

@ -369,4 +369,35 @@ gnc_build_data_path (const gchar *filename)
return result;
}
/** @fn gchar * gnc_build_report_path (const gchar *filename)
* @brief Make a path to filename in the report directory.
*
* @param filename The name of the file
*
* @return An absolute path.
*/
gchar *
gnc_build_report_path (const gchar *filename)
{
gchar *result = g_build_filename(gnc_path_get_reportdir(), filename, (gchar *)NULL);
return result;
}
/** @fn gchar * gnc_build_stdreports_path (const gchar *filename)
* @brief Make a path to filename in the standard reports directory.
*
* @param filename The name of the file
*
* @return An absolute path.
*/
gchar *
gnc_build_stdreports_path (const gchar *filename)
{
gchar *result = g_build_filename(gnc_path_get_stdreportsdir(), filename, (gchar *)NULL);
return result;
}
/* =============================== END OF FILE ========================== */

View File

@ -29,7 +29,7 @@
#ifndef GNC_FILEPATH_UTILS_H
#define GNC_FILEPATH_UTILS_H
/** The xaccResolveFilePath() routine is a utility that will accept
/** The gnc_resolve_file_path() routine is a utility that will accept
* a fragmentary filename as input, and resolve it into a fully
* qualified path in the file system, i.e. a path that begins with
* a leading slash. First, the current working directory is
@ -45,5 +45,7 @@ const gchar *gnc_dotgnucash_dir (void);
gchar *gnc_build_dotgnucash_path (const gchar *filename);
gchar *gnc_build_book_path (const gchar *filename);
gchar *gnc_build_data_path (const gchar *filename);
gchar *gnc_build_report_path (const gchar *filename);
gchar *gnc_build_stdreports_path (const gchar *filename);
#endif /* GNC_FILEPATH_UTILS_H */

View File

@ -125,6 +125,20 @@ gchar *gnc_path_get_accountsdir()
return result;
}
/** Returns the file path to the report directory, usually
* "$prefix/share/gnucash/guile-modules/gnucash/report".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_reportdir()
{
gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
gchar *result = g_build_filename (pkgdatadir, "guile-modules",
"gnucash", "report", (char*)NULL);
g_free (pkgdatadir);
//printf("Returning stdreportsdir %s\n", result);
return result;
}
/** Returns the file path to the standard
* reports, usually
* "$prefix/share/gnucash/guile-modules/gnucash/report/standard-reports".
@ -132,10 +146,9 @@ gchar *gnc_path_get_accountsdir()
* @returns A newly allocated string. */
gchar *gnc_path_get_stdreportsdir()
{
gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
gchar *result = g_build_filename (pkgdatadir, "guile-modules",
"gnucash", "report", "standard-reports", (char*)NULL);
g_free (pkgdatadir);
gchar *reportdir = gnc_path_get_reportdir ();
gchar *result = g_build_filename (reportdir, "standard-reports", (char*)NULL);
g_free (reportdir);
//printf("Returning stdreportsdir %s\n", result);
return result;
}

View File

@ -74,6 +74,12 @@ gchar *gnc_path_get_localedir(void);
* @returns A newly allocated string. */
gchar *gnc_path_get_accountsdir(void);
/** Returns the file path to the report directory, usually
* "$prefix/share/gnucash/guile-modules/gnucash/report".
*
* @returns A newly allocated string. */
gchar *gnc_path_get_reportdir(void);
/** Returns the file path to the standard
* reports, usually
* "$prefix/share/gnucash/guile-modules/gnucash/report/standard-reports".

View File

@ -27,8 +27,9 @@
; using all of these seems like overkill --
; not sure which are really required
(use-modules (gnucash main))
(use-modules (gnucash gnc-module))
(use-modules (gnucash gnc-module))
(use-modules (gnucash app-utils))
(use-modules (gnucash core-utils))
(use-modules (gnucash business-utils))
(gnc:module-load "gnucash/report/report-system" 0)
(gnc:module-load "gnucash/business-utils" 0)
@ -77,22 +78,14 @@
;; Find the file 'fname', and return its full path.
;; First look in the user's .gnucash directory.
;; Then look in Gnucash's standard report directory.
;; This is complicated because of the need to cater for
;; various operating systems; so it takes a fairly heuristic,
;; 'best guess' approach.
;; If no file is found, returns just 'fname' for use in error messages.
;; Note: this has been tested on Linux and Windows Vista so far...
(let* ((userdir (sub-vicinity (user-vicinity) ".gnucash"))
(sysdir (sub-vicinity (sub-vicinity (user-vicinity) "gnucash") "report"))
(home (or (home-vicinity)
(getenv "USERPROFILE")
(user-vicinity)
"")))
(let* ((userpath (gnc-build-dotgnucash-path fname))
(syspath (gnc-build-report-path fname)))
; make sure there's a trailing delimiter
(set! home (sub-vicinity (user-vicinity) home))
(let ((home-template (in-vicinity (in-vicinity home userdir) fname)))
(if (access? home-template R_OK)
home-template
(or (%search-load-path (in-vicinity sysdir fname))
fname)))))
(if (access? userpath R_OK)
userpath
(if (access? syspath R_OK)
syspath
fname))))

View File

@ -36,9 +36,9 @@
(use-modules (gnucash gnc-module))
(use-modules (gnucash business-utils))
(use-modules (gnucash report eguile-gnc))
(use-modules (gnucash report eguile-utilities))
(use-modules (ice-9 regex)) ; for regular expressions
(use-modules (ice-9 slib)) ; for 'vicinity' functions
(use-modules (srfi srfi-13)) ; for extra string functions
(gnc:module-load "gnucash/report/report-system" 0)
@ -127,29 +127,6 @@
(cc 'add com (gnc-numeric-neg num))
(cc 'add com num)))
(define (find-file fname)
;; Find the file 'fname', and return its full path.
;; First look in the user's .gnucash directory.
;; Then look in Gnucash's standard report directory.
;; This is complicated because of the need to cater for
;; various operating systems; so it takes a fairly heuristic,
;; 'best guess' approach.
;; If no file is found, returns just 'fname' for use in error messages.
;; Note: this has been tested on Linux and Windows Vista so far...
(let* ((userdir (sub-vicinity (user-vicinity) ".gnucash"))
(sysdir (sub-vicinity (sub-vicinity (user-vicinity) "gnucash") "report"))
(home (or (home-vicinity)
(getenv "USERPROFILE")
(user-vicinity)
"")))
; make sure there's a trailing delimiter
(set! home (sub-vicinity (user-vicinity) home))
(let ((home-template (in-vicinity (in-vicinity home userdir) fname)))
(if (access? home-template R_OK)
home-template
(or (%search-load-path (in-vicinity sysdir fname))
fname)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Define an account record for cacheing information about all the accounts