Skip to content

'relative' broken on Windows for network paths #347

Description

@martin5233

Commit 11beaba changed the approach for canonical on Windows, which leads to malfunction of the 'relative' function applied to cases, where the first argument is not on the same drive as the second. Previously this returned an empty path and/or an error code, which is no longer the case. Now this leads to non-existent paths like ''......\C$\temp\somefile" without any indication of an error.

How to reproduce:
On the command line issue the following commands to define network path mappings to two different drives, e.g.

net use X: \\localhost\C$\temp
net use B: \\localhost\E$\somedir
touch C:\temp\somefile
mkdir E:\somedir\test

The following test program

int main() {
    boost::filesystem::path abs("X:/somefile");
    boost::filesystem::path relToDest("B:/test");
    boost::system::error_code ec;

    auto relMapped = boost::filesystem::relative("X:/somefile", "B:/test", ec);

    std::cout << "relative path: " << relMapped << "\n";
    std::cout << "error code: " << ec << "\n";

    return 0;
}

returns:

relative path: "..\..\..\C$\temp\somefile"
error code: system:0

The same issue occurs with 'real' network paths, the above example is only to make this reproduceable on a local machine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions