This is a much simplified version of a program to check if the symbolic link is linked to the proper directory:
#include<boost/filesystem.hpp>#include<iostream>intmain(){boost::filesystem::pathdirectory="c:\\T4 2.0\\Data";boost::filesystem::pathsymlink="c:\\T4 2.0\\ApplicationSymlinks\\T4";boost::filesystem::pathpath_linked_to("");path_linked_to=boost::filesystem::read_symlink(symlink);// Resolve symlink. path_linked_to is not absolute. L"\\T4 2.0\\Data"path_linked_to=boost::filesystem::absolute(path_linked_to);// Absolute path. L"c:\\T4 2.0\\Data"if(directory==path_linked_to)std::cout<<"paths are equal"<<std::endl;elsestd::cout<<"paths are not equal"<<std::endl;return0;}
The output is "paths are not equal". Shouldn't they be equal? In the autos window of the debugger I do see this:
directory size 14 capacity 15`
where as
path_linked_to size 16 capacity 23` because it includes two trailing '\0's.
These two trailing '\0's are introduced in read_symlink.
How do I resolve this? Why doesn't read_symlink return an absolute? Why does read_symlink add in two trailing '\0's (assuming that is the problem)? Why does operator== not ignore the '\0's?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Windows 10
MS VS 2015
C++11
Boost 1.60
I create this symbolic link:
This is a much simplified version of a program to check if the symbolic link is linked to the proper directory:
The output is "paths are not equal". Shouldn't they be equal? In the autos window of the debugger I do see this:
where as
These two trailing '\0's are introduced in read_symlink.
How do I resolve this? Why doesn't read_symlink return an absolute? Why does read_symlink add in two trailing '\0's (assuming that is the problem)? Why does operator== not ignore the '\0's?