[Boost-bugs] [Boost C++ Libraries] #13428: Windows: "is_symlink" for drive letter (without trailing directory separator) returns the wrong result

Subject: [Boost-bugs] [Boost C++ Libraries] #13428: Windows: "is_symlink" for drive letter (without trailing directory separator) returns the wrong result
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-01-30 13:39:23


#13428: Windows: "is_symlink" for drive letter (without trailing directory
separator) returns the wrong result
-------------------------------------------------+-------------------------
 Reporter: m.kosch@… | Owner: Beman Dawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.66.0 | Severity: Problem
 Keywords: symlink is_symlink canonical |
  weakly_canonical GetFileAttributes |
  GetFileAttributesW |
-------------------------------------------------+-------------------------
 Suppose you have a normal directory {{{Dir}}} and a symlink named
 {{{SymlinkToDir}}} which points to {{{Dir}}} on drive {{{C:\}}}.

 The following two tests lead to different results:
 {{{
 boost::filesystem::path fsPathToSymlink("C:\\SymlinkToDir");
 boost::filesystem::path fsPathToDrive("C:");

 current_path(fsPathToDrive + "\\");
 bool b1 = is_symlink(fsPathToDrive);
 assert( b1 == false );

 current_path(fsPathToSymlink);
 bool b2 = is_symlink(fsPathToDrive);
 assert( b2 == true );
 }}}

 It seems that Windows differentiates between {{{C:}}} and {{{C:\}}}. The
 first form seems to denote the current directory on drive {{{C:\}}} while
 the second form seems to denote drive {{{C:\}}} itself. This also can be
 observed in the Windows command promt.

 {{{is_symlink}}} internally uses {{{GetFileAttributesW}}} to determine the
 symlink status. {{{GetFileAttributes("C:")}}} returns the file attributes
 of {{{C:\\SymlinkToDir}}} instead of {{{C:\}}}.

 The function {{{is_symlink}}} is used to implement other functions, so
 this problem also effects at least the following other functions, possibly
 even many more:

 * {{{canonical}}} returns {{{BOOST_ERROR_NOT_SUPPORTED}}} for an absolute
 path, if compiled for Windows versions earlier than Windows Vista
 ({{{_WIN32_WINNT < 0x0600}}}) and the current directory represents a
 symlink.

 * {{{weakly_canonical}}} in the same scenario as above, because this
 utilizes {{{canonical}}}.

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13428>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2018-01-30 13:44:51 UTC