gulrak / filesystem

An implementation of C++17 std::filesystem for C++11 /C++14/C++17/C++20 on Windows, macOS, Linux and FreeBSD.
MIT License
1.34k stars 173 forks source link

filesystem::canonical fails to resolve relative path to a mapped folder #124

Closed HamedSabri-adsk closed 3 years ago

HamedSabri-adsk commented 3 years ago

Describe the bug

It appears to be a bug in gulark's filesystem::canonical which fails to properly resolve relative path to a mapped drive. C++17 std::filesystem::canonical doesn't have this issue and properly resolves the relative path.

In this scenario C:\MOUNT_ME is a folder that is mapped to a folder on an external hard drive G:\RTS on Windows:

    Plugin and external drive or USB Drive to your computer.
    Go to Disk Manager.
    Right Click on your connected drive.
    Select "Change Drive Letter and Path..."
    Select "Add".
    Use "Mount in the following empty NTFS folder:"
    Locate the folder you want to mount to.

ghc::filesystem::canonical

auto fullPath = ghc::filesystem::path(currentFileDir).append(relativeFilePath); 
// C:\\MOUNT_ME\\RTS\\RTS\\master_files\\..\\referenced_files\\USD\\barrelTests\\Library\\Assets\\Barrels\\Barrels.usd
auto path = ghc::filesystem::canonical(fullPath, errorCode); // error 

std::filesystem::canonical

auto fullPath = std::filesystem::path(currentFileDir).append(relativeFilePath);
//"C:\\MOUNT_ME\\RTS\\RTS\\master_files\\../referenced_files/USD/barrelTests/Library/Assets/Barrels/Barrels.usd"
auto path = std::filesystem::canonical(fullPath, errorCode); // Ok, good 

Expected behavior ghc::filesystem::canonical should behave similar to std::filesystem::canonical.

Additional context https://github.com/Autodesk/maya-usd/pull/1422

gulrak commented 3 years ago

Thanks for reporting this! I'll try to get a fix into v1.5.6 scheduled for Sunday.

HamedSabri-adsk commented 3 years ago

Awesome! Thank you for quick response.

gulrak commented 3 years ago

Sorry for the delay, working on fixing up the new release now, should be out in a an hour or two.

gulrak commented 3 years ago

This is now part of release v1.5.6