diff --git a/SimoxUtility/filesystem/make_relative.h b/SimoxUtility/filesystem/make_relative.h index 77bf25be26bc00599f5e1a90261dd5cc629689f8..48d203ebc6448891be19ecaee681707412833c75 100644 --- a/SimoxUtility/filesystem/make_relative.h +++ b/SimoxUtility/filesystem/make_relative.h @@ -5,16 +5,21 @@ namespace simox::fs { //! Return path when appended to a_From will resolve to same as a_To - inline std::filesystem::path make_relative(std::filesystem::path a_From, std::filesystem::path a_To) + inline std::filesystem::path + make_relative(std::filesystem::path a_From, std::filesystem::path a_To) { a_From = std::filesystem::canonical(a_From); a_To = std::filesystem::canonical(a_To); std::filesystem::path ret; std::filesystem::path::const_iterator itrFrom(a_From.begin()), itrTo(a_To.begin()); // Find common base - for (std::filesystem::path::const_iterator toEnd(a_To.end()), fromEnd(a_From.end()); itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo; ++itrFrom, ++itrTo); + for (std::filesystem::path::const_iterator toEnd(a_To.end()), fromEnd(a_From.end()); + itrFrom != fromEnd && itrTo != toEnd && *itrFrom == *itrTo; + ++itrFrom, ++itrTo) + ; // Navigate backwards in directory to reach previously found base - for (std::filesystem::path::const_iterator fromEnd(a_From.end()); itrFrom != fromEnd; ++itrFrom) + for (std::filesystem::path::const_iterator fromEnd(a_From.end()); itrFrom != fromEnd; + ++itrFrom) { if ((*itrFrom) != ".") ret /= ".."; @@ -25,4 +30,4 @@ namespace simox::fs ret /= *itrTo; return ret; } -} +} // namespace simox::fs