summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_model_load.c
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2014-12-10 18:31:20 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-12-23 21:20:20 +0100
commit61aab62be0e17fd58405debbc0f6befae66e64c8 (patch)
tree04b0b3ed39562f702fc0686a3e9d044ab5977579 /src/lib/evas/common/evas_model_load.c
parent17baa3fa6f87227fdba4caaea5e5c2a39257f5bb (diff)
evas: entry points to modules is Eina_File. Model_Common_Loader is deleted.
Diffstat (limited to '')
-rw-r--r--src/lib/evas/common/evas_model_load.c69
1 files changed, 14 insertions, 55 deletions
diff --git a/src/lib/evas/common/evas_model_load.c b/src/lib/evas/common/evas_model_load.c
index 4ccb30cfad..0598d31e21 100644
--- a/src/lib/evas/common/evas_model_load.c
+++ b/src/lib/evas/common/evas_model_load.c
@@ -7,68 +7,28 @@
7#include "evas_common_private.h" 7#include "evas_common_private.h"
8#include "evas_private.h" 8#include "evas_private.h"
9 9
10static inline void
11_model_common_loader_fini(Model_Common_Loader *loader)
12{
13 if (loader->map)
14 {
15 eina_file_map_free(loader->file, loader->map);
16 loader->map = NULL;
17 }
18
19 if (loader->file)
20 {
21 eina_file_close(loader->file);
22 loader->file = NULL;
23 }
24}
25
26static inline Eina_Bool
27_model_common_loader_init(Model_Common_Loader *loader, const char *file)
28{
29 Eina_File *tmp_file = eina_file_open(file, 0);
30 memset(loader, 0x00, sizeof(Model_Common_Loader));
31
32 /* Open given file. */
33 loader->file = eina_file_dup(tmp_file);
34
35 if (loader->file == NULL)
36 {
37 ERR("Failed to open file %s\n", file);
38 goto error;
39 }
40
41 /* Map the file. */
42 loader->map = eina_file_map_all(loader->file, EINA_FILE_SEQUENTIAL);
43
44 if (loader->map == NULL)
45 {
46 ERR("Failed to create map from file %s\n", file);
47 goto error;
48 }
49
50 eina_file_close(tmp_file);
51 return EINA_TRUE;
52
53error:
54 eina_file_close(tmp_file);
55 _model_common_loader_fini(loader);
56 return EINA_FALSE;
57}
58
59void 10void
60evas_common_load_model_to_file(Evas_3D_Mesh *model, const char *file) 11evas_common_load_model_to_file(Evas_3D_Mesh *model, const char *file)
61{ 12{
62 char *p; 13 char *p;
63 char *loader_type = NULL; 14 char *loader_type = NULL;
64 Model_Common_Loader *loader = malloc(sizeof(Model_Common_Loader));
65 15
66 if (!_model_common_loader_init(loader, file)) 16 Eina_File *tmp_file = eina_file_open(file, 0);
17 Eina_File *e_file = eina_file_dup(tmp_file);
18
19 if (e_file == NULL)
67 { 20 {
21 ERR("Failed to open file %s\n", file);
22 eina_file_close(tmp_file);
23 eina_file_close(e_file);
24 e_file = NULL;
25 file = NULL;
68 ERR("Failed to initialize loader."); 26 ERR("Failed to initialize loader.");
69 return; 27 return;
70 } 28 }
71 29
30 eina_file_close(tmp_file);
31
72 p = strrchr(file, '.'); 32 p = strrchr(file, '.');
73 if (p) 33 if (p)
74 { 34 {
@@ -76,7 +36,7 @@ evas_common_load_model_to_file(Evas_3D_Mesh *model, const char *file)
76#define CHECK_EXTENTION_BY_FILE_NAME(extention) \ 36#define CHECK_EXTENTION_BY_FILE_NAME(extention) \
77 if (!strcasecmp(p, #extention)) \ 37 if (!strcasecmp(p, #extention)) \
78 { \ 38 { \
79 evas_model_load_file_##extention(model, loader); \ 39 evas_model_load_file_##extention(model, e_file); \
80 loader_type = #extention; \ 40 loader_type = #extention; \
81 } 41 }
82 CHECK_EXTENTION_BY_FILE_NAME(eet) 42 CHECK_EXTENTION_BY_FILE_NAME(eet)
@@ -87,7 +47,6 @@ evas_common_load_model_to_file(Evas_3D_Mesh *model, const char *file)
87 } 47 }
88 if (!loader_type) ERR("Invalid mesh file type."); 48 if (!loader_type) ERR("Invalid mesh file type.");
89 49
90 _model_common_loader_fini(loader); 50 eina_file_close(e_file);
91 free(loader); 51 e_file = NULL;
92} 52}
93