From 61396654a5b477405ab473d11f6b9d8a9d95219e Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Thu, 27 Jun 2013 12:23:33 +0900 Subject: [PATCH] efreet: cleanup code by using Eina_File infra. --- src/lib/efreet/efreet_mime.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/lib/efreet/efreet_mime.c b/src/lib/efreet/efreet_mime.c index 15cb5ff..4c52d16 100644 --- a/src/lib/efreet/efreet_mime.c +++ b/src/lib/efreet/efreet_mime.c @@ -993,31 +993,22 @@ efreet_mime_count_digits(int in) static void efreet_mime_shared_mimeinfo_magic_load(const char *file) { - int fd = -1, size; - char *data = (void *)-1; + Eina_File *f; + void *data; if (!file) return; - size = ecore_file_size(file); - if (size <= 0) return; - - fd = open(file, O_RDONLY); - if (fd == -1) return; - - /* let's make mmap safe and just get 0 pages for IO erro */ - eina_mmap_safety_enabled_set(EINA_TRUE); + f = eina_file_open(file, EINA_FALSE); + if (!f) return ; - data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); - if (data == MAP_FAILED) - { - close(fd); - return; - } + data = eina_file_map_all(f, EINA_FILE_WILLNEED); + if (!data) goto end; - efreet_mime_shared_mimeinfo_magic_parse(data, size); + efreet_mime_shared_mimeinfo_magic_parse(data, eina_file_size_get(f)); - munmap(data, size); - close(fd); + eina_file_map_free(f, data); + end: + eina_file_close(f); } /** -- 2.7.4