Commit 51b6e576 authored by Orivej Desh's avatar Orivej Desh Committed by Han-Wen Nienhuys

Set file stat mode and time

parent 45cd3924
...@@ -22,9 +22,11 @@ type ZipFile struct { ...@@ -22,9 +22,11 @@ type ZipFile struct {
} }
func (f *ZipFile) Stat(out *fuse.Attr) { func (f *ZipFile) Stat(out *fuse.Attr) {
// TODO - do something intelligent with timestamps. out.Mode = fuse.S_IFREG | uint32(f.File.Mode())
out.Mode = fuse.S_IFREG | 0444
out.Size = uint64(f.File.UncompressedSize) out.Size = uint64(f.File.UncompressedSize)
out.Mtime = uint64(f.File.ModTime().Unix())
out.Atime = out.Mtime
out.Ctime = out.Mtime
} }
func (f *ZipFile) Data() []byte { func (f *ZipFile) Data() []byte {
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"testing" "testing"
"time"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/nodefs"
...@@ -68,6 +69,16 @@ func TestZipFs(t *testing.T) { ...@@ -68,6 +69,16 @@ func TestZipFs(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Stat failed: %v", err) t.Fatalf("Stat failed: %v", err)
} }
if fi.Mode() != 0664 {
t.Fatalf("File mode 0%o != 0664", fi.Mode())
}
mtime, err := time.Parse(time.RFC3339, "2011-02-22T12:56:12Z")
if err != nil {
panic(err)
}
if !fi.ModTime().Equal(mtime) {
t.Fatalf("File mtime %v != %v", fi.ModTime(), mtime)
}
if fi.IsDir() { if fi.IsDir() {
t.Error("file type", fi) t.Error("file type", fi)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment