r18964 - gnucash/trunk/src/app-utils - Bug #613655 - Cannot load MYsql data, fix invalid state file name
Geert Janssens
gjanssens at code.gnucash.org
Thu Mar 25 18:08:34 EDT 2010
Author: gjanssens
Date: 2010-03-25 18:08:34 -0400 (Thu, 25 Mar 2010)
New Revision: 18964
Trac: http://svn.gnucash.org/trac/changeset/18964
Modified:
gnucash/trunk/src/app-utils/file-utils.c
Log:
Bug #613655 - Cannot load MYsql data, fix invalid state file name
Modified: gnucash/trunk/src/app-utils/file-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/file-utils.c 2010-03-25 20:45:07 UTC (rev 18963)
+++ gnucash/trunk/src/app-utils/file-utils.c 2010-03-25 22:08:34 UTC (rev 18964)
@@ -43,6 +43,7 @@
#include "gnc-engine.h"
#include "gnc-filepath-utils.h"
#include "gnc-gkeyfile-utils.h"
+#include "gnc-uri-utils.h"
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_GUILE;
@@ -255,11 +256,34 @@
gint i;
ENTER("url %s, guid %s", url, guid);
- tmp = strchr(url, ':');
- if (tmp)
- url = tmp + 1;
- basename = g_path_get_basename(url);
+ if ( gnc_uri_is_file_uri ( url ) )
+ {
+ /* The url is a true file, use its basename. */
+ gchar *path = gnc_uri_get_path ( url );
+ basename = g_path_get_basename ( path );
+ g_free ( path );
+ }
+ else
+ {
+ /* The url is composed of database connection parameters. */
+ gchar* protocol = NULL;
+ gchar* host = NULL;
+ gchar* dbname = NULL;
+ gchar* username = NULL;
+ gchar* password = NULL;
+ gint portnum = 0;
+ gnc_uri_get_components ( url, &protocol, &host, &portnum,
+ &username, &password, &dbname );
+
+ basename = g_strjoin("_", protocol, host, username, dbname, NULL);
+ g_free( protocol );
+ g_free( host );
+ g_free( username );
+ g_free( password );
+ g_free( dbname );
+ }
+
DEBUG("Basename %s", basename);
original = gnc_build_book_path(basename);
g_free(basename);
More information about the gnucash-changes
mailing list