This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/2]: Refactor relocate_path to also check if the relocated file/directory exists
On Wed, 19 Sep 2012 21:53:16 +0200, Khoo Yit Phang wrote:
> -relocate_path (const char *progname, const char *initial, int flag)
> +relocate_path (const char *progname, const char *initial, int isdir,
> + int flag)
> {
> if (flag)
> - return make_relative_prefix (progname, BINDIR, initial);
> + {
> + char *path;
> + path = make_relative_prefix (progname, BINDIR, initial);
> + if (path)
> + {
> + struct stat s;
> +
> + if (stat (path, &s) != 0 || (isdir && !S_ISDIR (s.st_mode)))
OK just you could also check if !isdir, therefore:
if (stat (path, &s) != 0 || (isdir && !S_ISDIR (s.st_mode))
|| (!isdir && S_ISDIR (s.st_mode)))
(I would write it differently but reviews here point to this style.)
Thanks,
Jan