예제 #1
0
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")
}
예제 #2
0
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
}