Move gnc-filepath-utils and dependencies from engine to core-utils

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18811 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2010-03-04 16:32:54 +00:00
parent 2e5c6f1cee
commit 58680c35b8
9 changed files with 26 additions and 55 deletions

View File

@ -1,11 +1,14 @@
lib_LTLIBRARIES = libgnc-core-utils.la
libgnc_core_utils_la_SOURCES = \
binreloc.c \
gnc-main.c \
gnc-filepath-utils.c \
gnc-gconf-utils.c \
gnc-gdate-utils.c \
gnc-gkeyfile-utils.c \
gnc-glib-utils.c \
gnc-path.c \
swig-core-utils.c
libgnc_core_utils_la_LIBADD = \
@ -14,11 +17,14 @@ libgnc_core_utils_la_LIBADD = \
${GCONF_LIBS}
noinst_HEADERS = \
binreloc.h \
gnc-main.h \
gnc-filepath-utils.h \
gnc-gconf-utils.h \
gnc-gdate-utils.h \
gnc-gkeyfile-utils.h \
gnc-glib-utils.h
gnc-glib-utils.h \
gnc-path.h
if BUILDING_FROM_SVN
swig-core-utils.c: core-utils.i ${top_srcdir}/src/base-typemaps.i
@ -30,6 +36,7 @@ AM_CPPFLAGS = \
${GUILE_INCS} \
${GLIB_CFLAGS} \
${GCONF_CFLAGS} \
-I${top_srcdir}/src/libqof/qof \
-I${top_srcdir}/src
@ -57,8 +64,20 @@ if ! OS_WIN32
endif
noinst_DATA = .scm-links
EXTRA_DIST = $(gncmod_DATA) core-utils.i
EXTRA_DIST = $(gncmod_DATA) core-utils.i gncla-dir.h.in
CLEANFILES = gnucash .scm-links
MAINTAINERCLEANFILES = swig-core-utils.c
BUILT_SOURCES = gncla-dir.h
INCLUDES = -DG_LOG_DOMAIN=\"gnc.core-utils\"
gncla-dir.h: gncla-dir.h.in ${top_builddir}/config.status Makefile
rm -f $@.tmp
sed < $< > $@.tmp \
-e 's#@-DATADIRNAME-@#${DATADIRNAME}#g' \
-e 's#@-libdir-@#${libdir}#g' \
-e 's#@-sysconfdir-@#${sysconfdir}#g' \
-e 's#@-datadir-@#${datadir}#g' \
-e 's#@-prefix-@#${prefix}#g'
mv $@.tmp $@

View File

@ -47,7 +47,7 @@
#endif
#include <errno.h>
#include "gnc-engine.h"
#include "qof.h"
#include "gnc-path.h"
#include "gnc-filepath-utils.h"
@ -56,9 +56,6 @@
#define PATH_MAX MAXPATHLEN
#endif
static QofLogModule log_module = GNC_MOD_BACKEND;
/**
* Scrubs a filename by changing "strange" chars (e.g. those that are not
* valid in a win32 file name) to "_".
@ -88,12 +85,8 @@ scrub_filename(char* filename)
static gchar *
check_path_return_if_valid(gchar *path)
{
ENTER("Path: %s", path);
if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
{
LEAVE("found %s", path);
return path;
}
g_free (path);
return NULL;
}
@ -131,25 +124,19 @@ xaccResolveFilePath (const char * filefrag)
/* seriously invalid */
if (!filefrag)
{
PERR("filefrag is NULL");
g_critical("filefrag is NULL");
return NULL;
}
ENTER ("filefrag=%s", filefrag);
/* ---------------------------------------------------- */
/* OK, now we try to find or build an absolute file path */
/* check for an absolute file path */
if (g_path_is_absolute(filefrag))
{
LEAVE("filefrag is absolute path");
return g_strdup (filefrag);
}
if (!g_ascii_strncasecmp(filefrag, "file:", 5))
{
LEAVE("filefrag is file uri");
if (!g_ascii_strncasecmp(filefrag, "file://", 7))
return g_strdup(filefrag + 7);
else
@ -157,7 +144,6 @@ xaccResolveFilePath (const char * filefrag)
}
if ( g_ascii_strncasecmp( filefrag, "xml:", 4 ) == 0 )
{
LEAVE( "filefrag is xml file uri" );
if ( g_ascii_strncasecmp( filefrag, "xml://", 6 ) == 0 )
return g_strdup( filefrag + 6);
else
@ -175,10 +161,7 @@ xaccResolveFilePath (const char * filefrag)
g_free(tmp_path);
fullpath = check_path_return_if_valid(fullpath);
if (fullpath != NULL)
{
LEAVE("found %s", fullpath);
return fullpath;
}
/* Look in the data dir (e.g. $PREFIX/share/gnucash) */
tmp_path = gnc_path_get_pkgdatadir();
@ -186,10 +169,7 @@ xaccResolveFilePath (const char * filefrag)
g_free(tmp_path);
fullpath = check_path_return_if_valid(fullpath);
if (fullpath != NULL)
{
LEAVE("found %s", fullpath);
return fullpath;
}
/* Look in the config dir (e.g. $PREFIX/etc/gnucash) */
tmp_path = gnc_path_get_accountsdir();
@ -197,21 +177,15 @@ xaccResolveFilePath (const char * filefrag)
g_free(tmp_path);
fullpath = check_path_return_if_valid(fullpath);
if (fullpath != NULL)
{
LEAVE("found %s", fullpath);
return fullpath;
}
/* Look in the users config dir (e.g. $HOME/.gnucash/data) */
fullpath = gnc_build_data_path(filefrag);
if (g_file_test(fullpath, G_FILE_TEST_IS_REGULAR))
{
LEAVE("found %s", fullpath);
return fullpath;
}
/* OK, it's not there. Note that it needs to be created and pass it
* back anyway */
LEAVE("create new file %s", fullpath);
g_warning("create new file %s", fullpath);
return fullpath;
}

View File

@ -24,10 +24,6 @@
* @brief File path resolution utility functions
* @author Copyright (c) 1998-2004 Linas Vepstas <linas@linas.org>
* @author Copyright (c) 2000 Dave Peticolas
*
* XXX this file does not belong in the gnucash engine; it is here
* for the moment only because both the file backend and the app-file
* GUI code make use of it. It should be moved away someday.
*/
#ifndef GNC_FILEPATH_UTILS_H

View File

@ -27,17 +27,14 @@ libgncmod_engine_la_SOURCES = \
Split.c \
TransLog.c \
Transaction.c \
binreloc.c \
cap-gains.c \
cashobjects.c \
gnc-associate-account.c \
gnc-budget.c \
gnc-commodity.c \
gnc-engine.c \
gnc-filepath-utils.c \
gnc-hooks.c \
gnc-lot.c \
gnc-path.c \
gnc-pricedb.c \
gnc-session.c \
gnc-session-scm.c \
@ -70,7 +67,6 @@ gncinclude_HEADERS = \
Split.h \
TransLog.h \
Transaction.h \
binreloc.h \
cap-gains.h \
cashobjects.h \
engine-helpers.h \
@ -80,9 +76,7 @@ gncinclude_HEADERS = \
gnc-commodity.h \
gnc-engine.h \
gnc-event.h \
gnc-filepath-utils.h \
gnc-hooks.h \
gnc-path.h \
gnc-pricedb.h \
gnc-session.h \
gnc-session-scm.h \
@ -135,7 +129,6 @@ EXTRA_DIST = \
extensions.txt \
iso-4217-currencies.scm \
iso-currencies-to-c \
gncla-dir.h.in \
kvp_doc.txt \
SX-book-p.h \
engine.i \
@ -178,20 +171,9 @@ iso-4217-currencies.c: iso-4217-currencies.scm iso-currencies-to-c
-chmod u+x ${srcdir}/iso-currencies-to-c
GUILE_LOAD_PATH=@GNC_SRFI_LOAD_PATH@:${GUILE_LOAD_PATH} srcdir=${srcdir} ${srcdir}/iso-currencies-to-c
gncla-dir.h: gncla-dir.h.in ${top_builddir}/config.status Makefile
rm -f $@.tmp
sed < $< > $@.tmp \
-e 's#@-DATADIRNAME-@#${DATADIRNAME}#g' \
-e 's#@-libdir-@#${libdir}#g' \
-e 's#@-sysconfdir-@#${sysconfdir}#g' \
-e 's#@-datadir-@#${datadir}#g' \
-e 's#@-prefix-@#${prefix}#g'
mv $@.tmp $@
BUILT_SOURCES = iso-4217-currencies.c
BUILT_SOURCES = iso-4217-currencies.c \
gncla-dir.h
CLEANFILES = $(BUILT_SOURCES) gnucash .scm-links gncla-dir.h \
CLEANFILES = $(BUILT_SOURCES) gnucash .scm-links \
${SCM_FILE_LINKS}
MAINTAINERCLEANFILES = swig-engine.c