some updates

This commit is contained in:
Henrique Dias
2016-06-10 20:54:19 +01:00
parent 0146f4324f
commit 4efb4f2a53
7 changed files with 253 additions and 281 deletions

29
fileinfo.go Normal file
View File

@@ -0,0 +1,29 @@
package filemanager
import (
"os"
"time"
"github.com/dustin/go-humanize"
)
// FileInfo is the info about a particular file or directory
type FileInfo struct {
IsDir bool
Name string
Size int64
URL string
ModTime time.Time
Mode os.FileMode
}
// HumanSize returns the size of the file as a human-readable string
// in IEC format (i.e. power of 2 or base 1024).
func (fi FileInfo) HumanSize() string {
return humanize.IBytes(uint64(fi.Size))
}
// HumanModTime returns the modified time of the file as a human-readable string.
func (fi FileInfo) HumanModTime(format string) string {
return fi.ModTime.Format(format)
}