diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/generators.c | 30 | ||||
| -rw-r--r-- | src/items.c | 6 | ||||
| -rw-r--r-- | src/job-manager.c | 39 | ||||
| -rw-r--r-- | src/setup.c | 2 |
4 files changed, 39 insertions, 38 deletions
diff --git a/src/generators.c b/src/generators.c index 2329953..a11ebcd 100644 --- a/src/generators.c +++ b/src/generators.c @@ -133,26 +133,26 @@ generate_image (TGallerySetup *setup, if (items->type == GALLERY_TYPE_INDEX) { if (item->thumbnail == NULL || strlen (item->thumbnail) == 0) return FALSE; - img_src_full = g_strconcat (path_info->src_dir, "/", item->thumbnail, NULL); - thumb_src_full = g_strconcat (path_info->src_dir, "/", item->thumbnail, NULL); + img_src_full = g_build_filename (path_info->src_dir, item->thumbnail, NULL); + thumb_src_full = g_build_filename (path_info->src_dir, item->thumbnail, NULL); } else if (items->type == GALLERY_TYPE_ALBUM) { s1 = (item->path == NULL && item->preview) ? item->preview : item->path; thumb_src_full = (item->thumbnail) ? item->thumbnail : s1; - img_src_full = g_strconcat (path_info->src_dir, "/", s1, NULL); - thumb_src_full = g_strconcat (path_info->src_dir, "/", thumb_src_full, NULL); + img_src_full = g_build_filename (path_info->src_dir, s1, NULL); + thumb_src_full = g_build_filename (path_info->src_dir, thumb_src_full, NULL); } /* Make paths */ s1 = item_get_thumbnail_src (setup, items, item, item_index); - thumb_dst = g_strconcat (path_info->dest_dir, "/", setup->thumbnail_dir, "/", s1, NULL); + thumb_dst = g_build_filename (path_info->dest_dir, setup->thumbnail_dir, s1, NULL); g_free (s1); s1 = item_get_img_src (setup, items, item); - big_dst = g_strconcat (path_info->dest_dir, "/", setup->img_big_dir, "/", s1, NULL); + big_dst = g_build_filename (path_info->dest_dir, setup->img_big_dir, s1, NULL); if (item->force_fullsize || setup->override_nofullsize || (items->fullsize && ! item->force_nofullsize) || (! item->force_nofullsize && ! items->nofullsize && ! setup->nofullsize)) - orig_dst = g_strconcat (path_info->dest_dir, "/", setup->img_orig_dir, "/", s1, NULL); + orig_dst = g_build_filename (path_info->dest_dir, setup->img_orig_dir, s1, NULL); res = (! update_when_necessary) || needs_update (thumb_src_full, thumb_dst) || (items->type == GALLERY_TYPE_ALBUM && (needs_update (img_src_full, big_dst) || (orig_dst && needs_update (img_src_full, orig_dst)))); g_free (s1); @@ -220,7 +220,7 @@ generate_image (TGallerySetup *setup, else { /* Copy the preview (big) image provided */ - big_src = g_strconcat (path_info->src_dir, "/", item->preview, NULL); + big_src = g_build_filename (path_info->src_dir, item->preview, NULL); if (! copy_file (big_src, big_dst)) log_error ("generate_image: error copying preview image %s\n", big_src); g_free (big_src); @@ -487,7 +487,7 @@ write_html_album (TGallerySetup *setup, replace_table_add_key (local_replace_table, "IMG_DESCRIPTION", item->title_description); replace_table_add_key_printf (local_replace_table, "IMG_LIST_ID", "i%d", i + 1); if (items->type == GALLERY_TYPE_INDEX) { - s3 = g_strconcat (path_info->src_dir, "/", item->path, "/index.xml", NULL); + s3 = g_build_filename (path_info->src_dir, item->path, "index.xml", NULL); replace_table_add_key_int (local_replace_table, "ALBUM_NUM_ITEMS", get_album_objects_count (s3)); g_free (s3); } @@ -630,15 +630,15 @@ write_html_image (TGallerySetup *setup, imgname = g_path_get_basename ((item->path == NULL && item->preview) ? item->preview : item->path); if (next_item && setup->preload) { s1 = g_path_get_basename ((next_item->path == NULL && next_item->preview) ? next_item->preview : next_item->path); - preload_imgname = g_strconcat (setup->img_big_dir, "/", s1, NULL); + preload_imgname = g_build_filename (setup->img_big_dir, s1, NULL); g_free (s1); } - big_dst = g_strconcat (path_info->dest_dir, "/", setup->img_big_dir, "/", imgname, NULL); - orig_dst = g_strconcat (path_info->dest_dir, "/", setup->img_orig_dir, "/", imgname, NULL); + big_dst = g_build_filename (path_info->dest_dir, setup->img_big_dir, imgname, NULL); + orig_dst = g_build_filename (path_info->dest_dir, setup->img_orig_dir, imgname, NULL); res = TRUE; /* Get EXIF data from the original image */ - s1 = g_strconcat (path_info->src_dir, "/", (item->path == NULL && item->preview) ? item->preview : item->path, NULL); + s1 = g_build_filename (path_info->src_dir, (item->path == NULL && item->preview) ? item->preview : item->path, NULL); exif = get_exif (s1); g_free (s1); if (exif == NULL) @@ -690,9 +690,9 @@ write_html_image (TGallerySetup *setup, if (title_desc) title_desc = g_strstrip (title_desc); /* Page title */ - s1 = (title && strlen (title) > 0) ? g_strdup_printf("%s | ", title) : NULL; + s1 = (title && strlen (title) > 0) ? g_strdup_printf ("%s | ", title) : NULL; s2 = g_strdup_printf ("%s [%d/%d]", parent_items->title ? parent_items->title : parent_items->ID, real_item_index, real_total_items); - s3 = setup->site_title ? g_strdup_printf(" | %s", setup->site_title) : NULL; + s3 = setup->site_title ? g_strdup_printf (" | %s", setup->site_title) : NULL; s4 = g_strconcat (s1 ? s1 : "", s2, s3 ? s3 : "", NULL); replace_table_add_key (replace_table, "PAGE_TITLE", s4); g_free (s1); diff --git a/src/items.c b/src/items.c index 4012980..faedead 100644 --- a/src/items.c +++ b/src/items.c @@ -227,18 +227,18 @@ parse_album_xml (const gchar *filename) /* Retrieve title and description from linked album if not defined here */ if (index->type == GALLERY_TYPE_INDEX && item->title == NULL && item->title_description == NULL) { - s = g_strconcat (base_dir, "/", item->path, "/index.xml", NULL); + s = g_build_filename (base_dir, item->path, "index.xml", NULL); get_album_titles (s, &item->title, &item->title_description, NULL); g_free (s); } /* Retrieve thumbnail from linked album if not defined here */ if (index->type == GALLERY_TYPE_INDEX && item->thumbnail == NULL) { - s = g_strconcat (base_dir, "/", item->path, "/index.xml", NULL); + s = g_build_filename (base_dir, item->path, "index.xml", NULL); s2 = NULL; get_album_titles (s, NULL, NULL, &s2); if (s2) { - item->thumbnail = g_strconcat (item->path, "/", s2, NULL); + item->thumbnail = g_build_filename (item->path, s2, NULL); g_free (s2); } g_free (s); diff --git a/src/job-manager.c b/src/job-manager.c index 11beebb..174c28a 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -69,7 +69,7 @@ mirror_files (TGallerySetup *setup, gchar **files, const gchar *src_tree, const s1 = g_strstrip (*extra); if (strlen (s1) > 0) { /* First create target directory if it doesn't exist */ - s2 = g_strconcat (dst_dir, "/", s1, NULL); + s2 = g_build_filename (dst_dir, s1, NULL); s3 = g_path_get_dirname (s2); g_free (s2); if (g_mkdir_with_parents (s3, DEFAULT_DATA_DIR_MODE)) { @@ -80,8 +80,8 @@ mirror_files (TGallerySetup *setup, gchar **files, const gchar *src_tree, const g_free (s3); /* Copy the file */ - s2 = g_strconcat (src_tree, "/", s1, NULL); - s3 = g_strconcat (dst_dir, "/", s1, NULL); + s2 = g_build_filename (src_tree, s1, NULL); + s3 = g_build_filename (dst_dir, s1, NULL); if (! setup->update_mode || needs_update (s2, s3)) { if (setup->verbose) { if (processed == 0) @@ -113,7 +113,7 @@ thread_func (gpointer data) { TIndexItem *item; gchar *imgname; - gchar *s1, *s3; + gchar *s1, *s2, *s3; TJob *job = data; gboolean updated; GList *l; @@ -148,10 +148,12 @@ thread_func (gpointer data) } if (updated && job->items->type == GALLERY_TYPE_ALBUM) { - s1 = g_strconcat (job->setup->real_templates_dir, "/", job->setup->template_photo, NULL); - s3 = g_strconcat (job->path_info->dest_dir, "/", imgname, GET_EXT (job->setup->index_file_name), NULL); + s1 = g_build_filename (job->setup->real_templates_dir, job->setup->template_photo, NULL); + s2 = g_strconcat (imgname, GET_EXT (job->setup->index_file_name), NULL); + s3 = g_build_filename (job->path_info->dest_dir, s2, NULL); write_html_image (job->setup, job->path_info, s1, s3, item, job->items); g_free (s1); + g_free (s2); g_free (s3); } g_free (imgname); @@ -185,7 +187,7 @@ build_tree (TGallerySetup *setup, gchar *thumb_dir; gchar *img_big_dir; gchar *img_orig_dir; - gchar *template; + const gchar *template; gchar *dst_album_file; gboolean res; int i; @@ -215,7 +217,7 @@ build_tree (TGallerySetup *setup, } /* Check the index file */ - idx_file = g_strconcat (path_info->src_dir, "/index.xml", NULL); + idx_file = g_build_filename (path_info->src_dir, "index.xml", NULL); if (access (idx_file, R_OK)) { log_error ("error accessing index file '%s': %s\n", idx_file, strerror (errno)); g_free (idx_file); @@ -233,7 +235,7 @@ build_tree (TGallerySetup *setup, items->parent_item_index = parent_item_index; /* Check if update is necessary */ - dst_album_file = g_strconcat (path_info->dest_dir, "/", setup->index_file_name, NULL); + dst_album_file = g_build_filename (path_info->dest_dir, setup->index_file_name, NULL); force_update = (! setup->update_mode || needs_update (idx_file, dst_album_file)); g_free (idx_file); @@ -245,8 +247,8 @@ build_tree (TGallerySetup *setup, /* favicon */ if (setup->favicon_file && strlen (setup->favicon_file) > 0) { s3 = g_path_get_dirname (setup->setup_xml_path); - s1 = g_strconcat (s3, "/", setup->favicon_file, NULL); - s2 = g_strconcat (path_info->dest_dir, "/", setup->favicon_file, NULL); + s1 = g_build_filename (s3, setup->favicon_file, NULL); + s2 = g_build_filename (path_info->dest_dir, setup->favicon_file, NULL); if (! setup->update_mode || needs_update (s1, s2)) { if (setup->verbose) printf (" Copying favicon: %s\n", setup->favicon_file); copy_file (s1, s2); @@ -258,7 +260,7 @@ build_tree (TGallerySetup *setup, } /* Prepare target thumbnail directory */ - thumb_dir = g_strconcat (path_info->dest_dir, "/", setup->thumbnail_dir, NULL); + thumb_dir = g_build_path (G_DIR_SEPARATOR_S, path_info->dest_dir, setup->thumbnail_dir, NULL); if (access (thumb_dir, R_OK | W_OK | X_OK)) if (g_mkdir_with_parents (thumb_dir, DEFAULT_DATA_DIR_MODE)) { log_error ("error making target thumbnail directory: %s\n", strerror (errno)); @@ -273,8 +275,8 @@ build_tree (TGallerySetup *setup, if (items->type == GALLERY_TYPE_ALBUM) { res = TRUE; - img_big_dir = g_strconcat (path_info->dest_dir, "/", setup->img_big_dir, NULL); - img_orig_dir = g_strconcat (path_info->dest_dir, "/", setup->img_orig_dir, NULL); + img_big_dir = g_build_path (G_DIR_SEPARATOR_S, path_info->dest_dir, setup->img_big_dir, NULL); + img_orig_dir = g_build_path (G_DIR_SEPARATOR_S, path_info->dest_dir, setup->img_orig_dir, NULL); if (access (img_big_dir, R_OK | W_OK | X_OK)) if (g_mkdir_with_parents (img_big_dir, DEFAULT_DATA_DIR_MODE)) { log_error ("error making target preview directory: %s\n", strerror (errno)); @@ -366,19 +368,18 @@ build_tree (TGallerySetup *setup, /* Generate album page */ if (force_update) { if (items->type == GALLERY_TYPE_INDEX) - template = g_strconcat ("/", setup->template_index, NULL); + template = setup->template_index; else if (items->type == GALLERY_TYPE_ALBUM) - template = g_strconcat ("/", setup->template_album, NULL); + template = setup->template_album; else /* default to album */ - template = g_strconcat ("/", setup->template_album, NULL); + template = setup->template_album; if (setup->verbose) printf (" Writing %s\n", setup->index_file_name); - s1 = g_strconcat (setup->real_templates_dir, template, NULL); + s1 = g_build_filename (setup->real_templates_dir, template, NULL); res = write_html_album (setup, path_info, s1, dst_album_file, items); g_free (s1); - g_free (template); if (! res) { log_error ("error generating target index file\n"); free_album_data (items); diff --git a/src/setup.c b/src/setup.c index 6cc9ed6..68c3cd3 100644 --- a/src/setup.c +++ b/src/setup.c @@ -171,7 +171,7 @@ test_tmpl_access (const gchar *dir, const gchar *path) int b; s = g_build_filename (dir, path, NULL); - b = access (s, R_OK); + b = g_access (s, R_OK); g_free (s); return b; } |
