Author Topic: PCL: FileInfo f("").IsExecutable() is always true...  (Read 3113 times)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
PCL: FileInfo f("").IsExecutable() is always true...
« on: 2015 January 10 06:14:17 »
... but file "" is never executable.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: PCL: FileInfo f("").IsExecutable() is always true...
« Reply #1 on: 2015 January 10 07:39:23 »
Same if path is Directory ("/usr/bin") or symbolic link ("/bin").
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PCL: FileInfo f("").IsExecutable() is always true...
« Reply #3 on: 2015 February 19 01:45:30 »
Same if path is Directory ("/usr/bin") or symbolic link ("/bin").

No, this is not a bug. Directories normally have the S_IXUSR permission flag set (along with S_IXGRP and S_IXOTH). For directories, "executable" means "searchable". This is a POSIX convention; see for example:

http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysstat.h.html

You should always check if a path actually refers to a file with either FileInfo.IsFile() or FileInfo.IsDirectory() and FileInfo.Exists(), as appropriate.

I have just updated the documentation for FileInfo::IsExecutable() to clarify this:
https://github.com/PixInsight/PCL/commit/a1dedcaff28802ba9d08394d571e59e700c4d6fe
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: PCL: FileInfo f("").IsExecutable() is always true...
« Reply #4 on: 2015 February 19 04:47:39 »
Fine with me. As long as it works as documented, I am happy. It is just a little bit surprising...
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)