summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-06-27 12:23:33 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-06-27 15:19:43 +0900
commit61396654a5b477405ab473d11f6b9d8a9d95219e (patch)
tree648b9ea90505ec762a7c9e3fdae3ea0498022025
parentf24dea2a90e7edcd64013af39bb7a0832334d1ed (diff)
efreet: cleanup code by using Eina_File infra.
-rw-r--r--src/lib/efreet/efreet_mime.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/lib/efreet/efreet_mime.c b/src/lib/efreet/efreet_mime.c
index 15cb5ff751..4c52d1669c 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)
993static void 993static void
994efreet_mime_shared_mimeinfo_magic_load(const char *file) 994efreet_mime_shared_mimeinfo_magic_load(const char *file)
995{ 995{
996 int fd = -1, size; 996 Eina_File *f;
997 char *data = (void *)-1; 997 void *data;
998 998
999 if (!file) return; 999 if (!file) return;
1000 1000
1001 size = ecore_file_size(file); 1001 f = eina_file_open(file, EINA_FALSE);
1002 if (size <= 0) return; 1002 if (!f) return ;
1003
1004 fd = open(file, O_RDONLY);
1005 if (fd == -1) return;
1006
1007 /* let's make mmap safe and just get 0 pages for IO erro */
1008 eina_mmap_safety_enabled_set(EINA_TRUE);
1009 1003
1010 data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); 1004 data = eina_file_map_all(f, EINA_FILE_WILLNEED);
1011 if (data == MAP_FAILED) 1005 if (!data) goto end;
1012 {
1013 close(fd);
1014 return;
1015 }
1016 1006
1017 efreet_mime_shared_mimeinfo_magic_parse(data, size); 1007 efreet_mime_shared_mimeinfo_magic_parse(data, eina_file_size_get(f));
1018 1008
1019 munmap(data, size); 1009 eina_file_map_free(f, data);
1020 close(fd); 1010 end:
1011 eina_file_close(f);
1021} 1012}
1022 1013
1023/** 1014/**