Use existing PAX headers for time

This removes the MSWINDOWS.* time fields and uses PAX times directly. I
didn't previously realize that PAX times could be negative, which
eliminates the need to store Windows times in a different format.

This also uses the LIBARCHIVE.creationtime field for creation times to
match OS X behavior.
This commit is contained in:
John Starks
2016-03-30 12:38:03 -07:00
parent 8f9387ea7e
commit 424d62c72e
29 changed files with 126 additions and 81 deletions
+20 -1
View File
@@ -4,6 +4,8 @@ import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"
"github.com/Microsoft/go-winio"
@@ -61,5 +63,22 @@ func TestRoundTrip(t *testing.T) {
t.Fatal(err)
}
ensurePresent(t, hdr.Winheaders, "fileattr", "sd", "accesstime", "changetime", "createtime", "writetime")
name, size, bi2, err := FileInfoFromHeader(hdr)
if err != nil {
t.Fatal(err)
}
if name != filepath.ToSlash(f.Name()) {
t.Errorf("got name %s, expected %s", name, filepath.ToSlash(f.Name()))
}
if size != fi.Size() {
t.Errorf("got size %d, expected %d", size, fi.Size())
}
if !reflect.DeepEqual(*bi, *bi2) {
t.Errorf("got %#v, expected %#v", *bi, *bi2)
}
ensurePresent(t, hdr.Winheaders, "fileattr", "sd")
}