From: Vincent Torri Date: Tue, 14 Jun 2011 07:02:14 +0000 (+0000) Subject: From: Vincent Torri X-Git-Tag: submit/2.0alpha-wayland/20121127.221958~757 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=345a754690b4322b9da2ff0fcdcb8c423b4a7317;p=profile%2Fivi%2Fedje.git 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) git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@60299 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/bin/edje_cc_out.c b/src/bin/edje_cc_out.c index 650e959..fd2500e 100644 --- a/src/bin/edje_cc_out.c +++ b/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);