func (fs rfs) Stat(name string, islstat bool) (*sftpd.Attr, error) { p, e := rfsMangle(name) if e != nil { return nil, e } var fi os.FileInfo if islstat { fi, e = os.Lstat(p) } else { fi, e = os.Stat(p) } if e != nil { return nil, e } var a sftpd.Attr e = a.FillFrom(fi) return &a, e }
func (fs synthetic) Stat(path string, islstat bool) (*sftpd.Attr, error) { var a sftpd.Attr log.Println("STAT", path) if path == "" || path == "/" || path == "." { a.Flags = sftpd.ATTR_MODE a.Mode = sftpd.MODE_DIR | 0755 return &a, nil } if path[0] == '/' { path = path[1:] } f, ok := synthRoot.m[path] if ok { f.fillAttr(&a) log.Println("STAT FILE", f, a) return &a, nil } return nil, errors.New("not found") }
func (f *synthFile) fillAttr(attr *sftpd.Attr) { attr.Flags = sftpd.ATTR_SIZE | sftpd.ATTR_MODE attr.Size = uint64(len(f.bs)) attr.Mode = sftpd.MODE_REGULAR | 0644 }