From 36b21249d9e052aea5650463f069d96c4a15366a Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Tue, 14 Jun 2011 07:02:14 +0000 Subject: [PATCH] From: Vincent Torri Subject: [E-devel] Edje: using fdopen instead of fopen in edje_cc On windows, using open() followed by fopen() does not work. Hence, in edje_cc, where mkstemp (which uses open) is followed by fopen, edje_cc fails. Instead of fopen, we can use fdopen. I pasted a patch below. Can you comment it (like, instead of keeping the filename in the function that i modified, why not using it for the fd? (changes - closefd) removed from data_write_scripts() as fclose() handles that) SVN revision: 60299 --- legacy/edje/src/bin/edje_cc_out.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c index 650e959907..fd2500eba6 100644 --- a/legacy/edje/src/bin/edje_cc_out.c +++ b/legacy/edje/src/bin/edje_cc_out.c @@ -708,9 +708,9 @@ data_write_groups(Eet_File *ef, int *collection_num) } static void -create_script_file(Eet_File *ef, const char *filename, const Code *cd) +create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd) { - FILE *f = fopen(filename, "wb"); + FILE *f = fdopen(fd, "wb"); if (!f) error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.\n", filename); @@ -787,7 +787,7 @@ create_script_file(Eet_File *ef, const char *filename, const Code *cd) static void compile_script_file(Eet_File *ef, const char *source, const char *output, - int script_num) + int script_num, int fd) { FILE *f; char buf[4096]; @@ -802,7 +802,7 @@ compile_script_file(Eet_File *ef, const char *source, const char *output, if (ret < 0 || ret > 1) error_and_abort(ef, "Compiling script code not clean.\n"); - f = fopen(output, "rb"); + f = fdopen(fd, "rb"); if (!f) error_and_abort(ef, "Unable to open script object \"%s\" for reading.\n", output); @@ -864,8 +864,7 @@ data_write_scripts(Eet_File *ef) error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.\n", tmpn); - create_script_file(ef, tmpn, cd); - close(fd); + create_script_file(ef, tmpn, cd, fd); snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir); fd = mkstemp(tmpo); @@ -875,9 +874,7 @@ data_write_scripts(Eet_File *ef) error_and_abort(ef, "Unable to open temp file \"%s\" for script " "compilation.\n", tmpn); } - - compile_script_file(ef, tmpn, tmpo, i); - close(fd); + compile_script_file(ef, tmpn, tmpo, i, fd); unlink(tmpn); unlink(tmpo);