diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-04-25 15:39:55 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-04-25 15:39:55 +0200 |
| commit | 40334d2dec0545100edcca403d50ad6b1b015a9a (patch) | |
| tree | 70e76683eec8b4036d23f2253ea65ddb06d7c8dd /src/cgg.c | |
| parent | 54f18873efeef6e0ae4ac8cb46c15d0a1bee37f5 (diff) | |
| download | cataract-40334d2dec0545100edcca403d50ad6b1b015a9a.tar.xz | |
Update mode
By doing update, cgg will check the output structure for missing files and re-generate them as necessary. The decision
whether an item (file, picture, album) needs to be updated is done by comparing timestamps (mtime specifically). Due to that reason it's important to
keep this fact in mind when replacing single image which carries older timestamp than other files. Either don't use the update mode or 'touch' that
new file. Changes made to any XML file will result in whole album re-generation (excluding subalbums).
Diffstat (limited to 'src/cgg.c')
| -rw-r--r-- | src/cgg.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -44,19 +44,21 @@ * parse_cmd: parse commandline and fill global variable parameters */ gboolean -parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *verbose, int *jobs) +parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean *verbose, int *jobs, gboolean *update) { static gboolean _verbose = FALSE; static gchar *_source_dir = NULL; static gchar *_dst_dir = NULL; static int _jobs = 1; + static gboolean _update = FALSE; static GOptionEntry entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &_verbose, "Be verbose", NULL }, - { "source", 's', 0, G_OPTION_ARG_STRING, &_source_dir, "Specifies path to source structure", NULL }, + { "source", 's', 0, G_OPTION_ARG_STRING, &_source_dir, "Specifies a path to source structure", NULL }, { "output", 'o', 0, G_OPTION_ARG_STRING, &_dst_dir, "Generate files to the specified directory instead of current", NULL }, { "jobs", 'j', 0, G_OPTION_ARG_INT, &_jobs, "Allow N jobs at once (default=1)", NULL }, + { "update", 'u', 0, G_OPTION_ARG_NONE, &_update, "Update the output structure", NULL }, { NULL } }; @@ -73,7 +75,7 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean * g_option_context_add_main_entries (context, entries, NULL); if (argc == 1) { - s1 = g_option_context_get_help (context, TRUE, NULL); + s1 = g_option_context_get_help (context, TRUE, NULL); g_print ("%s", s1); g_free (s1); g_option_context_free (context); @@ -82,7 +84,7 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean * if (! g_option_context_parse (context, &argc, &argv, &error)) { g_print ("option parsing failed: %s\n", error->message); - s1 = g_option_context_get_help (context, TRUE, NULL); + s1 = g_option_context_get_help (context, TRUE, NULL); g_print ("%s", s1); g_free (s1); g_option_context_free (context); @@ -94,6 +96,7 @@ parse_cmd (int argc, char* argv[], char **source_dir, char **dst_dir, gboolean * *dst_dir = _dst_dir; *verbose = _verbose; *jobs = _jobs; + *update = _update; return TRUE; } @@ -106,6 +109,7 @@ main(int argc, char* argv[]) char *source_dir; char *dst_dir; gboolean verbose; + gboolean update; int jobs; TGallerySetup *setup; time_t time_start = time (NULL); @@ -130,7 +134,7 @@ main(int argc, char* argv[]) /* Parse commandline */ - if (! parse_cmd (argc, argv, &source_dir, &dst_dir, &verbose, &jobs)) + if (! parse_cmd (argc, argv, &source_dir, &dst_dir, &verbose, &jobs, &update)) return -1; if ((! source_dir) || (access (source_dir, R_OK))) { @@ -165,6 +169,7 @@ main(int argc, char* argv[]) /* Start building the gallery tree */ setup->verbose = verbose; + setup->update_mode = update; build_tree (setup, source_dir, dst_dir, NULL, -1, jobs); if (verbose) { |
