Opened 4 years ago

#13642 new Bugs

Strange behaviour of filesystem::relative on Windows

Reported by: martin.apel@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.67.0 Severity: Problem
Keywords: windows relative Cc:

Description

The following code snippet behaves unexpected under Windows:

   path base("C:\\Temp");
   path contained ("c:\\temp\\test");

   path result = relative(contained, base);

   std::cout << "relative returns " << result.generic_string() << "\n";

It returns an empty path, though the expected result would be something like ".\test". This is due to a case sensitive comparison, which is not consistent with how Windows treats path names.

I understand that this is the way it is documented, but if Boost.Filesystem is understood to be an abstraction layer over different operating systems, this is definitely not the desired behaviour.

I have attached a patch, which fixes the problem.

Attachments (1)

bfs-relative.patch (1.2 KB ) - added by martin.apel@… 4 years ago.

Download all attachments as: .zip

Change History (1)

by martin.apel@…, 4 years ago

Attachment: bfs-relative.patch added
Note: See TracTickets for help on using tickets.