format MimeTypeHelper
This commit is contained in:
parent
12090f7930
commit
fc1ca1e1b0
@ -11,7 +11,7 @@ enum SOURCE{
|
|||||||
const UTF8 := "UTF-8"
|
const UTF8 := "UTF-8"
|
||||||
|
|
||||||
class MimeType:
|
class MimeType:
|
||||||
|
|
||||||
var full_type := "application/octet-stream"
|
var full_type := "application/octet-stream"
|
||||||
var type := "application"
|
var type := "application"
|
||||||
var sub_type := "octet-stream"
|
var sub_type := "octet-stream"
|
||||||
@ -49,20 +49,20 @@ class MimeTypeDb:
|
|||||||
|
|
||||||
|
|
||||||
func process_raw_db(raw_db: Dictionary) -> void:
|
func process_raw_db(raw_db: Dictionary) -> void:
|
||||||
|
|
||||||
for type in raw_db:
|
for type in raw_db:
|
||||||
var mime_type := MimeType.new()
|
var mime_type := MimeType.new()
|
||||||
mime_type.setup(type, raw_db[type])
|
mime_type.setup(type, raw_db[type])
|
||||||
|
|
||||||
if not mime_type.extensions or type == _default_mime_type.type:
|
if not mime_type.extensions or type == _default_mime_type.type:
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for extension in mime_type.extensions:
|
for extension in mime_type.extensions:
|
||||||
if extension in _types and (_types[extension] as MimeType).source > mime_type.source:
|
if extension in _types and (_types[extension] as MimeType).source > mime_type.source:
|
||||||
continue
|
continue
|
||||||
_types[extension] = mime_type
|
_types[extension] = mime_type
|
||||||
|
|
||||||
|
|
||||||
func get(ext_or_filename: String) -> MimeType:
|
func get(ext_or_filename: String) -> MimeType:
|
||||||
var ext := ("x."+ext_or_filename.trim_prefix(".")).get_extension().to_lower()
|
var ext := ("x."+ext_or_filename.trim_prefix(".")).get_extension().to_lower()
|
||||||
if not (ext in _types):
|
if not (ext in _types):
|
||||||
|
Loading…
Reference in New Issue
Block a user