X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afh.c;h=567b560a038f0923a663005b447a0fc688c57b2a;hp=9d40caeb8b33fb7442bb1f822af7f6eba0a2c332;hb=3685a9093ae12ff9ce02fc58e607eb9b63894443;hpb=5710a297f747081a85218637c3777e6d189d786c diff --git a/afh.c b/afh.c index 9d40caeb..567b560a 100644 --- a/afh.c +++ b/afh.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 2008 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2008 Andre Noll , see file COPYING. */ /** \file afh.c Paraslash's standalone audio format handler tool. */ @@ -117,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 */ @@ -207,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);