61 lines
1.0 KiB
Go
61 lines
1.0 KiB
Go
package gowebdav
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
// File is our structure for a given file
|
|
type File struct {
|
|
path string
|
|
name string
|
|
size int64
|
|
modified time.Time
|
|
isdir bool
|
|
}
|
|
|
|
// Name returns the name of a file
|
|
func (f File) Name() string {
|
|
return f.name
|
|
}
|
|
|
|
// Size returns the size of a file
|
|
func (f File) Size() int64 {
|
|
return f.size
|
|
}
|
|
|
|
// Mode will return the mode of a given file
|
|
func (f File) Mode() os.FileMode {
|
|
// TODO check webdav perms
|
|
if f.isdir {
|
|
return 0775 | os.ModeDir
|
|
}
|
|
|
|
return 0664
|
|
}
|
|
|
|
// ModTime returns the modified time of a file
|
|
func (f File) ModTime() time.Time {
|
|
return f.modified
|
|
}
|
|
|
|
// IsDir let us see if a given file is a directory or not
|
|
func (f File) IsDir() bool {
|
|
return f.isdir
|
|
}
|
|
|
|
// Sys ????
|
|
func (f File) Sys() interface{} {
|
|
return nil
|
|
}
|
|
|
|
// String lets us see file information
|
|
func (f File) String() string {
|
|
if f.isdir {
|
|
return fmt.Sprintf("Dir : '%s' - '%s'", f.path, f.name)
|
|
}
|
|
|
|
return fmt.Sprintf("File: '%s' SIZE: %d MODIFIED: %s", f.path, f.size, f.modified.String())
|
|
}
|