unexport fileInfo
Former-commit-id: e6492286dba14bb758f36da9a3f14d223e5b2d32
This commit is contained in:
22
info.go
22
info.go
@@ -13,8 +13,8 @@ import (
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
)
|
||||
|
||||
// FileInfo contains the information about a particular file or directory
|
||||
type FileInfo struct {
|
||||
// fileInfo contains the information about a particular file or directory.
|
||||
type fileInfo struct {
|
||||
Name string
|
||||
Size int64
|
||||
URL string
|
||||
@@ -31,12 +31,12 @@ type FileInfo struct {
|
||||
content []byte
|
||||
}
|
||||
|
||||
// GetInfo gets the file information and, in case of error, returns the
|
||||
// getInfo gets the file information and, in case of error, returns the
|
||||
// respective HTTP error code
|
||||
func GetInfo(url *url.URL, c *FileManager, u *user) (*FileInfo, error) {
|
||||
func getInfo(url *url.URL, c *FileManager, u *user) (*fileInfo, error) {
|
||||
var err error
|
||||
|
||||
i := &FileInfo{URL: c.PrefixURL + url.Path}
|
||||
i := &fileInfo{URL: c.PrefixURL + url.Path}
|
||||
i.VirtualPath = strings.Replace(url.Path, c.BaseURL, "", 1)
|
||||
i.VirtualPath = strings.TrimPrefix(i.VirtualPath, "/")
|
||||
i.VirtualPath = "/" + i.VirtualPath
|
||||
@@ -77,7 +77,7 @@ var textExtensions = [...]string{
|
||||
|
||||
// RetrieveFileType obtains the mimetype and a simplified internal Type
|
||||
// using the first 512 bytes from the file.
|
||||
func (i *FileInfo) RetrieveFileType() error {
|
||||
func (i *fileInfo) RetrieveFileType() error {
|
||||
i.Mimetype = mime.TypeByExtension(i.Extension)
|
||||
|
||||
if i.Mimetype == "" {
|
||||
@@ -128,7 +128,7 @@ func (i *FileInfo) RetrieveFileType() error {
|
||||
}
|
||||
|
||||
// Reads the file.
|
||||
func (i *FileInfo) Read() error {
|
||||
func (i *fileInfo) Read() error {
|
||||
if len(i.content) != 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -142,22 +142,22 @@ func (i *FileInfo) Read() error {
|
||||
}
|
||||
|
||||
// StringifyContent returns the string version of Raw
|
||||
func (i FileInfo) StringifyContent() string {
|
||||
func (i fileInfo) StringifyContent() string {
|
||||
return string(i.content)
|
||||
}
|
||||
|
||||
// HumanSize returns the size of the file as a human-readable string
|
||||
// in IEC format (i.e. power of 2 or base 1024).
|
||||
func (i FileInfo) HumanSize() string {
|
||||
func (i fileInfo) HumanSize() string {
|
||||
return humanize.IBytes(uint64(i.Size))
|
||||
}
|
||||
|
||||
// HumanModTime returns the modified time of the file as a human-readable string.
|
||||
func (i FileInfo) HumanModTime(format string) string {
|
||||
func (i fileInfo) HumanModTime(format string) string {
|
||||
return i.ModTime.Format(format)
|
||||
}
|
||||
|
||||
// CanBeEdited checks if the extension of a file is supported by the editor
|
||||
func (i FileInfo) CanBeEdited() bool {
|
||||
func (i fileInfo) CanBeEdited() bool {
|
||||
return i.Type == "text"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user