tobiasschulz / tar-cs

Automatically exported from code.google.com/p/tar-cs
Other
0 stars 0 forks source link

Modification time may be computed incorrectly #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
According to the specification

http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5&manpath=FreeBSD+8-current

Modification time (mtime) is computed as number of seconds since epoch taken as 
UTC time.

If a user passes a UTC datetime value the result TAR file will be invalid, 
since the TarHeader class computes timestamp as difference between TheEpoch 
constant taken as local time.

It is suggested to create TheEpoch constant with explicit choice of UTC date 
time:

DateTime TheEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

And it is also necessary to compute the difference appropriately:

long ts = (long) (LastModification.ToUniversalTime() - TheEpoch).TotalSeconds;

in the TarHeader.LastModificationString property.

Original issue reported on code.google.com by tpgalche...@gmail.com on 2 May 2012 at 9:41

GoogleCodeExporter commented 9 years ago

Original comment by vasilt...@gmail.com on 18 Jan 2014 at 8:54