forked from enlightenment/efl
efreet: cleanup code by using Eina_File infra.
This commit is contained in:
parent
f24dea2a90
commit
61396654a5
|
@ -993,31 +993,22 @@ efreet_mime_count_digits(int in)
|
||||||
static void
|
static void
|
||||||
efreet_mime_shared_mimeinfo_magic_load(const char *file)
|
efreet_mime_shared_mimeinfo_magic_load(const char *file)
|
||||||
{
|
{
|
||||||
int fd = -1, size;
|
Eina_File *f;
|
||||||
char *data = (void *)-1;
|
void *data;
|
||||||
|
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
size = ecore_file_size(file);
|
f = eina_file_open(file, EINA_FALSE);
|
||||||
if (size <= 0) return;
|
if (!f) return ;
|
||||||
|
|
||||||
fd = open(file, O_RDONLY);
|
data = eina_file_map_all(f, EINA_FILE_WILLNEED);
|
||||||
if (fd == -1) return;
|
if (!data) goto end;
|
||||||
|
|
||||||
/* let's make mmap safe and just get 0 pages for IO erro */
|
efreet_mime_shared_mimeinfo_magic_parse(data, eina_file_size_get(f));
|
||||||
eina_mmap_safety_enabled_set(EINA_TRUE);
|
|
||||||
|
|
||||||
data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
eina_file_map_free(f, data);
|
||||||
if (data == MAP_FAILED)
|
end:
|
||||||
{
|
eina_file_close(f);
|
||||||
close(fd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
efreet_mime_shared_mimeinfo_magic_parse(data, size);
|
|
||||||
|
|
||||||
munmap(data, size);
|
|
||||||
close(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue