Я использую стандартную Visual Studio 2019 C ++ 2a в качестве компилятора для кода.
std::filesystem::path parentPathX(argv[0]);
std::cout << "Running: " << argv[0] << std::endl;
std::cout << "Path wise: " << parentPathX.string() << std::endl;
std::filesystem::path parentPath = std::filesystem::canonical(parentPathX.parent_path());
String parentPath1 = parentPath.string();
//findAndReplaceAll(parentPath1, " ", "^ ");
std::cout << "Parent Path: " << parentPath1 << std::endl;
канонический или абсолютный, он не выдает требуемый вывод. Я не передаю всю команду в качестве аргумента, а cd
до этой папки и запускаю команду, что означает: ![enter image description here](https://i.stack.imgur.com/0hlMC.jpg)
Output with std::filesystem::canonical
C:\Users\Tarun Maganti\source\repos\MWPixelAggr\Release>MWPixelAggr.exe G:\Work\abc\M-4591.tif DN wgs84 G:\Work\abc\TestMP.xlsx 3
Running: MWPixelAggr.exe
Path wise: MWPixelAggr.exe
Is Absolute? 1
Parent Path:
As you can see in the image, I don't have any output of for the canonical code.
Output with std::filesystem::absolute
C:\Users\Tarun Maganti\source\repos\MWPixelAggr\Release>MWPixelAggr.exe G:\Work\abc\M-4591.tif DN wgs84 G:\Work\abc\TestMP.xlsx 3
Running: MWPixelAggr.exe
Path wise: MWPixelAggr.exe
Is Absolute? 1
Parent Path:
As you can see in the image, I don't have any output of for the absolute code.
Input:
A file which I'm running. Basically the /. Convert it into a canonical path/absolute path.
I tried absolute too and it also gave me the same output.
Update:
I tried the same code using boost filesystem, I got some output but not correct.
введите описание изображения здесь
C:\dasfsa/dsfafsa/sdfsa/a.exe
Что непригодно. Я могу вручную преобразовать этот backsla sh, но я не знаю, это какая-то особенность esoteri c или ошибка, и если это ошибка, я не знаю, где еще он изменит этот sla sh и как.
Вывод с boost::filesystem::canonical
C:\Users\Tarun Maganti\source\repos\MWPixelAggr\Release>MWPixelAggr.exe G:\Work\abc\M-4591.tif DN wgs84 G:\Work\abc\TestMP.xlsx 3
Running: MWPixelAggr.exe
Path wise: MWPixelAggr.exe
Is Absolute? 1
Parent Path: C:/Users\Tarun Maganti\source\repos\MWPixelAggr\Release
Как вы можете видеть на изображении, у меня нет вывода для кода boost :: canonical.