[llvm] r217625 - Misc cleanups to the FileSytem api.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Sep 11 14:55:03 PDT 2014


On 11 September 2014 17:18, Sean Silva <chisophugis at gmail.com> wrote:
> -      bool Exists;
> -      if (!sys::fs::exists(LockFileName.str(), Exists) && !Exists) {
> +      if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist)
> ==
> +          errc::no_such_file_or_directory) {
>
> Is there a reason you didn't just use the `bool exists(const Twine &Path)`
> helper here?

I didn't want to include any semantic change in the patch. The
original code would take the branch only if sys::fs::exists returned
no error. Using the simpler version would take the branch if there was
an error.

To see the difference consider something like "permission denied". It
would not take the branch originally and will not with the way it is
currently written, but would with

if (!sys::fs::exists(LockFileName.c_str()))

Now, it may be a bug in the code, but it is probably better to fix
that in another patch.

Cheers,
Rafael



More information about the llvm-commits mailing list