#14777 closed defect (fixed)

In wxFileName::Exists, make wxFILE_EXISTS_SYMLINK imply wxFILE_EXISTS_NO_FOLLOW

Reported by: dghart Owned by: vadz
Priority: normal Milestone: 2.9.5
Component: base Version: stable-latest
Keywords: wxFileName wxFILE_EXISTS_SYMLINK wxFILE_EXISTS_NO_FOLLOW Cc:
Blocked By: Blocking:
Patch: yes

Description

As mentioned in #14542, it makes no sense to call wxFileName::Exists(wxFILE_EXISTS_SYMLINK) without preventing symlink dereferencing; otherwise it would always return false. The attached patch implements this.

The default flag wxFILE_EXISTS_ANY contains wxFILE_EXISTS_SYMLINK, so wxFILE_EXISTS_NO_FOLLOW will be auto-added for this too. I suppose it would therefore be sensible to add it explicitly, though I've not done so here.

Attachments (2)

filename.diff download (4.3 KB) - added by dghart 23 months ago.
filename2.diff download (5.4 KB) - added by dghart 23 months ago.

Download all attachments as: .zip

Change History (5)

Changed 23 months ago by dghart

comment:1 follow-up: Changed 23 months ago by vadz

  • Owner set to vadz
  • Status changed from new to accepted

Interesting that you decided to do it like this, is there any advantage compared to just setting wxFILE_EXISTS_NO_FOLLOW bit in wxFILE_EXISTS_SYMLINK itself?

I.e. make it so that testing wxFILE_EXISTS_SYMLINK & wxFILE_EXISTS_NO_FOLLOW would simply return non-zero. Is there some problem with doing this? Because it seems simpler to me than the current patch...

Changed 23 months ago by dghart

comment:2 in reply to: ↑ 1 Changed 23 months ago by dghart

Replying to vadz:

Interesting that you decided to do it like this, is there any advantage compared to just setting wxFILE_EXISTS_NO_FOLLOW bit in wxFILE_EXISTS_SYMLINK itself?

No, it just didn't occur to me.

The alternative patch implements it that way. I had to set the wxFILE_EXISTS_NO_FOLLOW bit in wxFILE_EXISTS_ANY too, or Exists(wxFILE_EXISTS_ANY) would miss symlinks, and zero it out before testing for symlinks, so there's not much simplification.

Or maybe I missed something else...

comment:3 Changed 23 months ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [72777]) Make wxFILE_EXISTS_SYMLINK work on its own, without wxFILE_EXISTS_NO_FOLLOW.

Include the wxFILE_EXISTS_NO_FOLLOW bit in wxFILE_EXISTS_SYMLINK definition to
allow using just wxFileName::Exists(wxFILE_EXISTS_SYMLINK) which used to never
work because the link was followed.

Closes #14777.

Note: See TracTickets for help on using tickets.