summaryrefslogtreecommitdiff
path: root/src/job-manager.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2011-01-23 18:11:38 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2011-01-23 18:11:38 +0100
commit49abd46d162e1d5013a42947c200544b75ab9da1 (patch)
tree91a74f000839814a315356fd9ef7dfe787501853 /src/job-manager.c
parent7df97fbe8fa93141e7922a95f5ce0f9254bf41ab (diff)
downloadcataract-49abd46d162e1d5013a42947c200544b75ab9da1.tar.xz
Use g_build_{filename|path} when possible
This has a nice side effect of not having double slashes in paths anymore.
Diffstat (limited to 'src/job-manager.c')
-rw-r--r--src/job-manager.c39
1 files changed, 20 insertions, 19 deletions
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);