Re: [PATCH] create_directories: simplify and avoid repeated copying
Geert Bosch <bosch@gnat.com> writes:
Show 6 quoted lines
> Signed-off-by: Geert Bosch <bosch@gnat.com>
> ---
> I needed to change the logic of this function a bit for
> doing some local hacks^Wmodifications and thought it might
> be a slight improvement/simplification.
> No change in functionality and passed 'make test'.
I like the removal of repeated copying, but I wonder if the denser condition is really easier to read.
I tried to like it, but I needed to reindent it first, and then I needed to read it three times to convince myself that they are equivalent.
if (errno != EEXIST
|| ((!force || unlink(buf) || mkdir(buf, 0777))
&& (stat(buf, &st) || !S_ISDIR(st.st_mode))) )
die("cannot create directory at %s", buf);In the end, I managed to convince myself that this denser version is doing the same thing as the original, and it is nicer to see it in only three lines, I am not sure if it is easier to read anymore, judging from the time it took me to reach that conclusion...