summaryrefslogtreecommitdiff
path: root/src/analysis/project.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-12-01 21:07:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-12-01 21:07:32 (GMT)
commit106e06d33196ca124d6d27cc00a5898d6f96121d (patch)
treeb5f04abc246f3514a0cce4f06a42708dc7ece62c /src/analysis/project.c
parent1c9e36639b949cc765dab316825f9fec7af85a6e (diff)
Handled relative paths when loading and saving binary contents in projects.
Diffstat (limited to 'src/analysis/project.c')
-rw-r--r--src/analysis/project.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/analysis/project.c b/src/analysis/project.c
index ed60929..94b01a3 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -282,14 +282,20 @@ GStudyProject *g_study_project_open(GObject *ref, const char *filename)
access = calloc(access_len, sizeof(char));
snprintf(access, access_len, "/ChrysalideProject/Contents/Content[position()=%u]", i + 1);
- content = g_binary_content_new_from_xml(context, access);
+ content = g_binary_content_new_from_xml(context, access, filename);
status = get_node_prop_long_value(context, access, "state", &state);
free(access);
+ if (content == NULL)
+ {
+ log_variadic_message(LMT_ERROR, _("Unable to load the binary content #%u ; skipping..."), i);
+ continue;
+ }
+
if (!status)
{
- log_variadic_message(LMT_PROCESS, _("bad state for content '%s' ; skipping..."),
+ log_variadic_message(LMT_ERROR, _("Bad state for content '%s' ; skipping..."),
g_binary_content_describe(content, true));
continue;
}
@@ -375,6 +381,7 @@ bool g_study_project_save(GStudyProject *project, const char *filename)
bool result; /* Bilan à retourner */
xmlDocPtr xdoc; /* Document XML à créer */
xmlXPathContextPtr context; /* Contexte pour les recherches*/
+ const char *final; /* Lieu d'enregistrement final */
size_t i; /* Boucle de parcours */
size_t access_len; /* Taille d'un chemin interne */
char *access; /* Chemin pour une sous-config.*/
@@ -383,6 +390,8 @@ bool g_study_project_save(GStudyProject *project, const char *filename)
result &= (ensure_node_exist(xdoc, context, "/ChrysalideProject") != NULL);
+ final = filename != NULL ? filename : project->filename;
+
/* Enregistrement des contenus binaires attachés */
for (i = 0; i < project->contents_count && result; i++)
@@ -394,7 +403,7 @@ bool g_study_project_save(GStudyProject *project, const char *filename)
access = calloc(access_len, sizeof(char));
snprintf(access, access_len, "/ChrysalideProject/Contents/Content[position()=%zu]", i + 1);
- result = g_binary_content_save(project->contents[i].content, xdoc, context, access);
+ result = g_binary_content_save(project->contents[i].content, xdoc, context, access, final);
if (result)
result = add_long_attribute_to_node(xdoc, context, access, "state", project->contents[i].state);
@@ -420,7 +429,7 @@ bool g_study_project_save(GStudyProject *project, const char *filename)
/* Sauvegarde finale */
- result &= save_xml_file(xdoc, filename != NULL ? filename : project->filename);
+ result &= save_xml_file(xdoc, final);
if (result && filename != NULL)
{