mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Report fs cleanup - Add a few convenience functions
These will provide easy access to some of the most important scm related runtime directories
This commit is contained in:
@@ -56,6 +56,12 @@ void
|
||||
%newobject gnc_path_get_bindir;
|
||||
gchar * gnc_path_get_bindir(void);
|
||||
|
||||
%newobject gnc_path_get_scmdir;
|
||||
gchar * gnc_path_get_scmdir(void);
|
||||
|
||||
%newobject gnc_path_get_reportsdir;
|
||||
gchar * gnc_path_get_reportsdir(void);
|
||||
|
||||
%newobject gnc_path_get_stdreportsdir;
|
||||
gchar * gnc_path_get_stdreportsdir(void);
|
||||
|
||||
@@ -65,8 +71,12 @@ gchar * gnc_path_find_localized_html_file(const gchar *);
|
||||
%newobject gnc_build_userdata_path;
|
||||
gchar * gnc_build_userdata_path(const gchar *);
|
||||
|
||||
%newobject gnc_file_path_absolute;
|
||||
gchar *gnc_file_path_absolute (const gchar *, const gchar *);
|
||||
|
||||
gchar * gnc_build_report_path(const gchar *);
|
||||
gchar * gnc_build_stdreports_path(const gchar *);
|
||||
gchar * gnc_build_reports_path(const gchar *);
|
||||
|
||||
void gnc_scm_log_warn(const gchar *);
|
||||
void gnc_scm_log_error(const gchar *);
|
||||
|
||||
@@ -35,11 +35,15 @@
|
||||
|
||||
(re-export gnc-prefs-is-debugging-enabled)
|
||||
(re-export gnc-path-get-bindir)
|
||||
(re-export gnc-path-get-scmdir)
|
||||
(re-export gnc-path-get-reportsdir)
|
||||
(re-export gnc-path-get-stdreportsdir)
|
||||
(re-export gnc-path-find-localized-html-file)
|
||||
(re-export gnc-build-userdata-path)
|
||||
(re-export gnc-build-report-path)
|
||||
(re-export gnc-build-stdreports-path)
|
||||
(re-export gnc-build-reports-path)
|
||||
(re-export gnc-file-path-absolute)
|
||||
(re-export gnc-utf8?)
|
||||
(re-export gnc-utf8-strip-invalid-strdup)
|
||||
(re-export gnc-locale-from-utf8)
|
||||
|
||||
@@ -1024,6 +1024,21 @@ gnc_userdata_dir_as_path (void)
|
||||
return gnc_userdata_home;
|
||||
}
|
||||
|
||||
static const bfs::path&
|
||||
gnc_userconfig_dir_as_path (void)
|
||||
{
|
||||
if (gnc_userdata_home.empty())
|
||||
/* Don't create missing directories automatically except
|
||||
* if the target directory is the temporary directory. This
|
||||
* should be done properly at a higher level (in the gui
|
||||
* code most likely) very early in application startup.
|
||||
* This call is just a fallback to prevent the code from
|
||||
* crashing because no directories were configured. */
|
||||
gnc_filepath_init();
|
||||
|
||||
return gnc_userconfig_home;
|
||||
}
|
||||
|
||||
gchar *gnc_file_path_absolute (const gchar *prefix, const gchar *relative)
|
||||
{
|
||||
bfs::path path_relative (relative);
|
||||
@@ -1054,7 +1069,7 @@ gchar *gnc_file_path_absolute (const gchar *prefix, const gchar *relative)
|
||||
}
|
||||
|
||||
/** @fn gchar * gnc_build_userdata_path (const gchar *filename)
|
||||
* @brief Make a path to filename in the user's configuration directory.
|
||||
* @brief Make a path to filename in the user's gnucash data directory.
|
||||
*
|
||||
* @param filename The name of the file
|
||||
*
|
||||
@@ -1068,6 +1083,21 @@ gnc_build_userdata_path (const gchar *filename)
|
||||
return g_strdup((gnc_userdata_dir_as_path() / filename).string().c_str());
|
||||
}
|
||||
|
||||
/** @fn gchar * gnc_build_userconfig_path (const gchar *filename)
|
||||
* @brief Make a path to filename in the user's configuration directory.
|
||||
*
|
||||
* @param filename The name of the file
|
||||
*
|
||||
* @return An absolute path. The returned string should be freed by the user
|
||||
* using g_free().
|
||||
*/
|
||||
|
||||
gchar *
|
||||
gnc_build_userconfig_path (const gchar *filename)
|
||||
{
|
||||
return g_strdup((gnc_userconfig_dir_as_path() / filename).string().c_str());
|
||||
}
|
||||
|
||||
/* Test whether c is a valid character for a win32 file name.
|
||||
* If so return false, otherwise return true.
|
||||
*/
|
||||
@@ -1151,6 +1181,22 @@ gnc_build_report_path (const gchar *filename)
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @fn gchar * gnc_build_reports_path (const gchar *dirname)
|
||||
* @brief Make a path to dirname in the reports directory.
|
||||
*
|
||||
* @param dirname The name of the subdirectory
|
||||
*
|
||||
* @return An absolute path. The returned string should be freed by the user
|
||||
* using g_free().
|
||||
*/
|
||||
|
||||
gchar *
|
||||
gnc_build_reports_path (const gchar *dirname)
|
||||
{
|
||||
gchar *result = g_build_filename(gnc_path_get_reportsdir(), dirname, (gchar *)NULL);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** @fn gchar * gnc_build_stdreports_path (const gchar *filename)
|
||||
* @brief Make a path to filename in the standard reports directory.
|
||||
*
|
||||
|
||||
@@ -106,10 +106,12 @@ char * gnc_filepath_init (void);
|
||||
|
||||
const gchar *gnc_userdata_dir (void);
|
||||
gchar *gnc_build_userdata_path (const gchar *filename);
|
||||
gchar *gnc_build_userconfig_path (const gchar *filename);
|
||||
gchar *gnc_build_book_path (const gchar *filename);
|
||||
gchar *gnc_build_translog_path (const gchar *filename);
|
||||
gchar *gnc_build_data_path (const gchar *filename);
|
||||
gchar *gnc_build_report_path (const gchar *filename);
|
||||
gchar *gnc_build_reports_path (const gchar *dirname);
|
||||
gchar *gnc_build_stdreports_path (const gchar *filename);
|
||||
|
||||
const gchar *gnc_userconfig_dir (void);
|
||||
|
||||
@@ -170,11 +170,11 @@ gchar *gnc_path_get_accountsdir()
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the file path to the report directory, usually
|
||||
* "$prefix/share/gnucash/scm/gnucash/report".
|
||||
/** Returns the file path to the directory containing all guile scripts, usually
|
||||
* "$prefix/share/gnucash/scm".
|
||||
*
|
||||
* @returns A newly allocated string. */
|
||||
gchar *gnc_path_get_reportdir()
|
||||
gchar *gnc_path_get_scmdir()
|
||||
{
|
||||
/* Careful: if the cmake variable SCHEME_INSTALLED_SOURCE_DIR gets changed
|
||||
* in toplevel CMakeLists.txt, this path should probably change as well.
|
||||
@@ -187,13 +187,38 @@ gchar *gnc_path_get_reportdir()
|
||||
* runtime.
|
||||
*/
|
||||
gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
|
||||
gchar *result = g_build_filename (pkgdatadir, "scm",
|
||||
"gnucash", "report", (char*)NULL);
|
||||
gchar *result = g_build_filename (pkgdatadir, "scm", (char*)NULL);
|
||||
g_free (pkgdatadir);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the file path to the report directory, usually
|
||||
* "$prefix/share/gnucash/scm/gnucash/report".
|
||||
*
|
||||
* @returns A newly allocated string. */
|
||||
gchar *gnc_path_get_reportdir()
|
||||
{
|
||||
gchar *scmdir = gnc_path_get_scmdir ();
|
||||
gchar *result = g_build_filename (scmdir, "gnucash", "report", (char*)NULL);
|
||||
g_free (scmdir);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the file path to the reports directory, usually
|
||||
* "$prefix/share/gnucash/scm/gnucash/report/reports".
|
||||
*
|
||||
* @returns A newly allocated string. */
|
||||
gchar *gnc_path_get_reportsdir()
|
||||
{
|
||||
gchar *reportdir = gnc_path_get_reportdir ();
|
||||
gchar *result = g_build_filename (reportdir, "reports", NULL);
|
||||
g_free (reportdir);
|
||||
//printf("Returning reportsdir %s\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the file path to the standard
|
||||
* reports, usually
|
||||
* "$prefix/share/gnucash/scm/gnucash/report/reports/standard".
|
||||
|
||||
@@ -92,12 +92,24 @@ gchar *gnc_path_get_localedir(void);
|
||||
* @returns A newly allocated string. */
|
||||
gchar *gnc_path_get_accountsdir(void);
|
||||
|
||||
/** Returns the file path to the directory containing all guile scripts, usually
|
||||
* "$prefix/share/gnucash/scm".
|
||||
*
|
||||
* @returns A newly allocated string. */
|
||||
gchar *gnc_path_get_scmdir(void);
|
||||
|
||||
/** Returns the file path to the report directory, usually
|
||||
* "$prefix/share/gnucash/scm/gnucash/report".
|
||||
*
|
||||
* @returns A newly allocated string. */
|
||||
gchar *gnc_path_get_reportdir(void);
|
||||
|
||||
/** Returns the file path to the reports, usually
|
||||
* "$prefix/share/gnucash/scm/gnucash/report/reports".
|
||||
*
|
||||
* @returns A newly allocated string. */
|
||||
gchar *gnc_path_get_reportsdir(void);
|
||||
|
||||
/** Returns the file path to the standard
|
||||
* reports, usually
|
||||
* "$prefix/share/gnucash/scm/gnucash/report/reports/standard".
|
||||
|
||||
Reference in New Issue
Block a user