Ticket #14777 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

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: 2.9-svn
Keywords: wxFileName wxFILE_EXISTS_SYMLINK wxFILE_EXISTS_NO_FOLLOW Cc:
Blocked By: Patch: yes
Blocking:

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

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

Change History

Changed 8 months ago by dghart

follow-up: ↓ 2   Changed 8 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 8 months ago by dghart

in reply to: ↑ 1   Changed 8 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...

  Changed 8 months ago by VZ

  • status changed from accepted to closed
  • resolution set to fixed

(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.