edi_mime: Only map what is needed.

This commit is contained in:
Alastair Poole 2020-01-08 18:19:02 +00:00
parent fa11a56611
commit f2ef1377f9
1 changed files with 5 additions and 3 deletions

View File

@ -20,6 +20,8 @@ edi_mime_type_get(const char *path)
unsigned long long len;
Eina_Bool likely_text = EINA_TRUE;
if (!path) return NULL;
f = eina_file_open(path, EINA_FALSE);
if (!f) return efreet_mime_type_get(path);
@ -30,15 +32,15 @@ edi_mime_type_get(const char *path)
return "text/plain";
}
map = eina_file_map_all(f, EINA_FILE_POPULATE);
if (len > 2048) len = 2048;
map = eina_file_map_new(f, EINA_FILE_POPULATE, 0, len);
if (!map)
{
eina_file_close(f);
return efreet_mime_type_get(path);
}
if (len > 2048) len = 2048;
for (int i = 0; i < (int) len; i++)
{
if (map[i] == '\0')