* Vincent Torri <[email protected]> [2011-06-08 20:56:52 +0200]:
>
>
> On Tue, 7 Jun 2011, Lucas De Marchi wrote:
>
> >On Tue, Jun 7, 2011 at 8:24 PM, Vincent Torri <[email protected]> wrote:
> >>
> >>Hey,
> >>
> >>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?
> >
> >The patch looks a bit weird. IMO you should take one of the following
> >approaches (in order of preference):
> >
> >1) Pass only the file descriptor instead of the filename. This way you
> >will write to the file descriptor recently opened by mkstemp.
> >
> >2) call close(fd) before calling create_script_file() and
> >compile_script_file(). This is very ugly thing that should work as
> >well, however one might argument that there's a race because the file
> >might disappear between the call to mkstemp() -- its creation -- and
> >the above functions.
>
> woldn't it be better to directly call open, fdopen and close in the
> functions create_script_file() and compile_script_file() ?
You actually have no guarantees the file still exists... Someone could
have deleted the file meanwhile. But for this use-case this is just
being paranoid.
So, the easiest fix (and cleanest in my POV) would be the patch below
(untested);
Lucas De Marchi
Index: src/bin/edje_cc_out.c
===================================================================
--- src/bin/edje_cc_out.c (revision 59987)
+++ src/bin/edje_cc_out.c (working copy)
@@ -864,8 +864,8 @@
error_and_abort(ef, "Unable to open temp file \"%s\" for script "
"compilation.\n", tmpn);
+ close(fd);
create_script_file(ef, tmpn, cd);
- close(fd);
snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir);
fd = mkstemp(tmpo);
@@ -876,8 +876,8 @@
"compilation.\n", tmpn);
}
+ close(fd);
compile_script_file(ef, tmpn, tmpo, i);
- close(fd);
unlink(tmpn);
unlink(tmpo);
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel