X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=afh.c;h=e419d2708d7224aaa5330515b11d45947c0d5fab;hb=6663ff04ae902bdea92b35b3b8dbdccd459d9099;hp=aa6570e1abc33bfe38e9ce87bf87316707263473;hpb=2031b9cab9304b02c0372f73eef54d9501277031;p=paraslash.git diff --git a/afh.c b/afh.c index aa6570e1..e419d270 100644 --- a/afh.c +++ b/afh.c @@ -113,6 +113,24 @@ static int rewrite_tags(const char *name, int input_fd, void *map, goto out; } ret = xrename(tmp_name, name); + if (ret < 0) + goto out; + if (OPT_GIVEN(PRESERVE)) { + struct timespec times[2]; /* [0]: atime, [1]: mtime */ + times[0].tv_nsec = UTIME_OMIT; + times[1] = sb.st_mtim; + /* + * We might well have written a file of identical size. If we + * keep the mtime as well, we might fool backup applications + * like rsync which skip files whose size and mtime haven't + * changed. So we change the mtime slightly. + */ + times[1].tv_sec++; + if (futimens(output_fd, times) < 0) { + ret = -ERRNO_TO_PARA_ERROR(errno); + goto out; + } + } out: if (ret < 0 && output_fd >= 0) unlink(tmp_name); /* ignore errors */ @@ -141,7 +159,7 @@ static void print_chunk_table(struct afh_info *afhi, int audio_format_id, struct timeval tv; long unsigned from, to; const char *buf; - size_t len; + uint32_t len; tv_scale(i, &afhi->chunk_tv, &tv); from = tv2ms(&tv); tv_scale(i + 1, &afhi->chunk_tv, &tv); @@ -159,7 +177,7 @@ static void print_chunk_table(struct afh_info *afhi, int audio_format_id, printf("%td - %td", buf - (const char *)map, buf + len - (const char *)map); if (!OPT_GIVEN(PARSER_FRIENDLY)) - printf(" (%zu)", len); + printf(" (%u)", len); printf("\n"); } afh_close(ctx, audio_format_id); @@ -203,7 +221,6 @@ int main(int argc, char **argv) loglevel = OPT_UINT32_VAL(LOGLEVEL); version_handle_flag("afh", OPT_GIVEN(VERSION)); handle_help_flags(); - afh_init(); for (i = 0; i < lls_num_inputs(lpr); i++) { int ret2; const char *path = lls_input(i, lpr); @@ -241,5 +258,6 @@ out: PARA_ERROR_LOG("%s\n", errctx); if (ret < 0) PARA_EMERG_LOG("%s\n", para_strerror(-ret)); + lls_free_parse_result(lpr, CMD_PTR); return ret < 0? EXIT_FAILURE : EXIT_SUCCESS; }