From d769c3b82b245217703d243b3e83e7d8cb51af1f Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 3 Mar 2011 12:31:48 +0100 Subject: Fix atom feed paths And convert it to use global path info. --- src/cgg.c | 1 + src/items.c | 31 ++----------------------------- src/items.h | 11 ++++++----- src/job-manager.c | 3 ++- 4 files changed, 11 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/cgg.c b/src/cgg.c index f295077..0f72fb3 100644 --- a/src/cgg.c +++ b/src/cgg.c @@ -176,6 +176,7 @@ main (int argc, char* argv[]) path_info->src_dir = g_strdup (source_dir); path_info->dest_root = g_strdup (dst_dir); path_info->dest_dir = g_strdup (dst_dir); + path_info->album_path = g_strdup ("/"); build_tree (setup, path_info, NULL, -1, jobs); free_path_info (path_info); diff --git a/src/items.c b/src/items.c index 5fc1963..98f97d2 100644 --- a/src/items.c +++ b/src/items.c @@ -30,31 +30,6 @@ #include "atom-writer.h" -static gchar * -get_album_path (TAlbum *items) -{ - TIndexItem *parent_item; - TAlbum *parent; - int old_parent_item_index; - gchar *path; - gchar *s; - - path = NULL; - parent = items->parent_index; - old_parent_item_index = items->parent_item_index; - while (parent) { - parent_item = g_ptr_array_index (parent->items, old_parent_item_index); - if (! parent_item) - break; - s = g_strdup_printf ("/%s%s", parent_item->path, path ? path : ""); - g_free (path); - path = s; - old_parent_item_index = parent->parent_item_index; - parent = parent->parent_index; - } - - return path ? path : g_strdup ("/"); -} static void free_album_item (TIndexItem *item) @@ -73,7 +48,7 @@ free_album_item (TIndexItem *item) * parse_album_xml: XML parser for gallery index.xml files */ TAlbum * -parse_album_xml (const gchar *filename) +parse_album_xml (const gchar *filename, TPathInfo *path_info) { TXMLFile *xml; gchar *gallery_type; @@ -160,9 +135,7 @@ parse_album_xml (const gchar *filename) atom_feed_item_set_summary (feed_item, s2); g_free (s2); - s = get_album_path (index); - atom_feed_item_set_path (feed_item, s); - g_free (s); + atom_feed_item_set_path (feed_item, path_info->album_path); } } diff --git a/src/items.h b/src/items.h index 6aad2a8..e83961a 100644 --- a/src/items.h +++ b/src/items.h @@ -74,17 +74,18 @@ typedef struct { } TIndexItem; typedef struct { - gchar *source_root; - gchar *dest_root; - gchar *src_dir; - gchar *dest_dir; + gchar *source_root; /* relative or absolute path of the source root */ + gchar *dest_root; /* relative or absolute path of the output directory */ + gchar *src_dir; /* album source directory */ + gchar *dest_dir; /* album output directory */ + gchar *album_path; /* current path in the gallery hierarchy, starting with '/' */ } TPathInfo; /* * parse_album_xml: XML parser for gallery index.xml files */ -TAlbum * parse_album_xml (const gchar *filename); +TAlbum * parse_album_xml (const gchar *filename, TPathInfo *path_info); /* * free_album_data: free allocated album data diff --git a/src/job-manager.c b/src/job-manager.c index 1e088f8..c2188a9 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -224,7 +224,7 @@ build_tree (TGallerySetup *setup, } /* Read the index file and fill items array */ - items = parse_album_xml (idx_file); + items = parse_album_xml (idx_file, path_info); if (! items) { log_error ("error reading index file '%s'\n", idx_file); g_free (idx_file); @@ -394,6 +394,7 @@ build_tree (TGallerySetup *setup, child_path_info->dest_root = g_strdup (path_info->dest_root); child_path_info->src_dir = g_build_path (G_DIR_SEPARATOR_S, path_info->src_dir, item->path, NULL); child_path_info->dest_dir = g_build_path (G_DIR_SEPARATOR_S, path_info->dest_dir, item->path, NULL); + child_path_info->album_path = g_build_path (G_DIR_SEPARATOR_S, path_info->album_path, item->path, NULL); build_tree (setup, child_path_info, items, i, jobs); free_path_info (child_path_info); } -- cgit v1.2.3