fs: Add MimeTypeDirEntry to return the MimeType of a DirEntry

This commit is contained in:
Nick Craig-Wood 2018-05-13 10:36:49 +01:00
parent f162116132
commit aadbcce486

View File

@ -28,3 +28,17 @@ func MimeType(o ObjectInfo) (mimeType string) {
}
return MimeTypeFromName(o.Remote())
}
// MimeTypeDirEntry returns the MimeType of a DirEntry
//
// It returns "inode/directory" for directories, or uses
// MimeType(Object)
func MimeTypeDirEntry(item DirEntry) string {
switch x := item.(type) {
case Object:
return MimeType(x)
case Directory:
return "inode/directory"
}
return ""
}