2014-10-23 10:39:55 +02:00
|
|
|
package gowebdav
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-10-23 13:15:02 +02:00
|
|
|
"os"
|
2014-10-23 10:39:55 +02:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2014-10-23 13:15:02 +02:00
|
|
|
type File struct {
|
|
|
|
path string
|
2014-10-23 10:39:55 +02:00
|
|
|
name string
|
2014-10-23 13:15:02 +02:00
|
|
|
size int64
|
2014-10-23 10:39:55 +02:00
|
|
|
modified time.Time
|
2014-10-23 13:15:02 +02:00
|
|
|
isdir bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f File) Name() string {
|
|
|
|
return f.name
|
2014-10-23 10:39:55 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 13:15:02 +02:00
|
|
|
func (f File) Size() int64 {
|
|
|
|
return f.size
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f File) Mode() os.FileMode {
|
|
|
|
if f.isdir {
|
|
|
|
return 0777 | os.ModeDir
|
|
|
|
} else {
|
|
|
|
return 0622
|
|
|
|
}
|
2014-10-23 10:39:55 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 13:15:02 +02:00
|
|
|
func (f File) ModTime() time.Time {
|
2014-10-23 10:39:55 +02:00
|
|
|
return f.modified
|
|
|
|
}
|
|
|
|
|
2014-10-23 13:15:02 +02:00
|
|
|
func (f File) IsDir() bool {
|
|
|
|
return f.isdir
|
2014-10-23 10:39:55 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 13:15:02 +02:00
|
|
|
func (f File) Sys() interface{} {
|
|
|
|
return nil
|
2014-10-23 10:39:55 +02:00
|
|
|
}
|
|
|
|
|
2014-10-23 13:15:02 +02:00
|
|
|
func (f File) String() string {
|
|
|
|
if f.isdir {
|
|
|
|
return fmt.Sprintf("Directory: %s", f.name)
|
|
|
|
} else {
|
|
|
|
return fmt.Sprintf("File: %s SIZE: %d MODIFIED: %s", f.name, f.size, f.modified.String())
|
|
|
|
}
|
2014-10-23 10:39:55 +02:00
|
|
|
}
|