summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2012-10-18 09:12:04 +0000
committerSebastian Dransfeld <sd@tango.flipp.net>2012-10-18 09:12:04 +0000
commit39d78828668969a2853d526704d3a0ea552e9a10 (patch)
treebdb5f41b6757fcd6d4996181942d0d0fec80bf68 /legacy
parent9fe5e81ccb2eab86cb6663811f85642e25fe7d89 (diff)
efreet: simplify
Since we open the file, there is no need to check for file existance and a fstat call is nicer than ecore_file_size SVN revision: 78171
Diffstat (limited to 'legacy')
-rw-r--r--legacy/efreet/src/lib/efreet_xml.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/legacy/efreet/src/lib/efreet_xml.c b/legacy/efreet/src/lib/efreet_xml.c
index 9767d75afe..390499f274 100644
--- a/legacy/efreet/src/lib/efreet_xml.c
+++ b/legacy/efreet/src/lib/efreet_xml.c
@@ -86,27 +86,27 @@ efreet_xml_new(const char *file)
86 Efreet_Xml *xml = NULL; 86 Efreet_Xml *xml = NULL;
87 int size, fd = -1; 87 int size, fd = -1;
88 char *data = MAP_FAILED; 88 char *data = MAP_FAILED;
89 struct stat st;
89 90
90 if (!file) return NULL; 91 if (!file) return NULL;
91 if (!ecore_file_exists(file)) return NULL;
92
93 size = ecore_file_size(file);
94 if (size <= 0) goto efreet_error;
95 92
96 fd = open(file, O_RDONLY); 93 fd = open(file, O_RDONLY);
97 if (fd == -1) goto efreet_error; 94 if (fd == -1) goto efreet_error;
98 95
96 if (fstat(fd, &st) < 0) goto efreet_error;
97
99 /* let's make mmap safe and just get 0 pages for IO erro */ 98 /* let's make mmap safe and just get 0 pages for IO erro */
100 eina_mmap_safety_enabled_set(EINA_TRUE); 99 eina_mmap_safety_enabled_set(EINA_TRUE);
101 100
102 data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); 101 data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
103 if (data == MAP_FAILED) goto efreet_error; 102 if (data == MAP_FAILED) goto efreet_error;
104 103
105 error = 0; 104 error = 0;
105 size = st.st_size;
106 xml = efreet_xml_parse(&data, &size); 106 xml = efreet_xml_parse(&data, &size);
107 if (!xml || error) goto efreet_error; 107 if (!xml || error) goto efreet_error;
108 108
109 munmap(data, size); 109 munmap(data, st.st_size);
110 close(fd); 110 close(fd);
111 return xml; 111 return xml;
112 112