Re: [xz-devel] Preserve file time on MinGW

2016-05-12 Thread Lasse Collin
Hello and sorry for taking so long to reply.

On 2016-04-28 Martok wrote:
> xz when built for Windows with gcc on mingw32 or mingw-w64 does not
> preserve timestamps. I have found that this is because MinGW only
> provides utime() with filename as target, and this means that the
> file time is adjusted by io_copy_attrs() and then immediately reset
> to 'now' when the dest_fd is closed afterwards in io_close().
> 
> I have done a bit of digging and mingw actually has futime() (in
> ), but for some reason exports it only as _futime().
> Only utime() is wrapped with a non-underscore-version.
> 
> Using something like this in io_copy_attrs works just fine and would
> fix the issue...
>   (void)_futime(pair->dest_fd, );

It's a bit surprising that it works because docs say that _utime() and
_futime() are identical except that _futime() takes a file descriptor.
But since it works, it's probably the best fix. I will fix it in the
next release. Thanks.

> Alternatively systems that need a file name could maybe first close
> the file and then set the file time, but that would complicate
> things...

It would complicate a little but it would be OK too if there were no
other way.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode



[xz-devel] Preserve file time on MinGW

2016-04-27 Thread Martok
Hello List,

xz when built for Windows with gcc on mingw32 or mingw-w64 does not preserve
timestamps. I have found that this is because MinGW only provides utime() with
filename as target, and this means that the file time is adjusted by
io_copy_attrs() and then immediately reset to 'now' when the dest_fd is closed
afterwards in io_close().

I have done a bit of digging and mingw actually has futime() (in ),
but for some reason exports it only as _futime(). Only utime() is wrapped with a
non-underscore-version.

Using something like this in io_copy_attrs works just fine and would fix the
issue...
(void)_futime(pair->dest_fd, );

Alternatively systems that need a file name could maybe first close the file and
then set the file time, but that would complicate things...


Regards,
Martok