mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
30 lines
645 B
Go
30 lines
645 B
Go
|
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)
|
||
|
}
|