gowebdav/file.go

53 lines
755 B
Go
Raw Permalink Normal View History

2014-10-23 10:39:55 +02:00
package gowebdav
import (
"fmt"
"os"
2014-10-23 10:39:55 +02:00
"time"
)
type File struct {
path string
2014-10-23 10:39:55 +02:00
name string
size int64
2014-10-23 10:39:55 +02:00
modified time.Time
isdir bool
}
func (f File) Name() string {
return f.name
2014-10-23 10:39:55 +02:00
}
func (f File) Size() int64 {
return f.size
}
func (f File) Mode() os.FileMode {
2014-10-24 09:29:03 +02:00
// TODO check webdav perms
if f.isdir {
2014-10-24 09:29:03 +02:00
return 0775 | os.ModeDir
} else {
2014-10-24 09:29:03 +02:00
return 0664
}
2014-10-23 10:39:55 +02:00
}
func (f File) ModTime() time.Time {
2014-10-23 10:39:55 +02:00
return f.modified
}
func (f File) IsDir() bool {
return f.isdir
2014-10-23 10:39:55 +02:00
}
func (f File) Sys() interface{} {
return nil
2014-10-23 10:39:55 +02:00
}
func (f File) String() string {
if f.isdir {
2014-10-27 17:02:00 +01:00
return fmt.Sprintf("Dir : '%s' - '%s'", f.path, f.name)
} else {
2014-10-27 17:02:00 +01:00
return fmt.Sprintf("File: '%s' SIZE: %d MODIFIED: %s", f.path, f.size, f.modified.String())
}
2014-10-23 10:39:55 +02:00
}