I need to create a function that will remove anything such as '..' or '.' in a filepath. So if I did resolvePath("/root\\\\directory1/directory2\\\\\\\\..")
it would return "root/directory1
. I tried making a char* array of each part of the path but I couldn't get each segment of it.
The two really cross-platform alternatives are boost and Qt for this, so here goes it with both demonstrated:
path canonical(const path& p, const path& base = current_path());
path canonical(const path& p, system::error_code& ec);
path canonical(const path& p, const path& base, system::error_code& ec);
QFileInfo fileInfo("/root\\\\directory1/directory2\\\\\\\\.."))
qDebug() << fileInfo.canonicalFilePath();