int findSubDirectory(const filesystem::path& directory, const filesystem::path& path, filesystem::path& out_subdirectory) { int numMatchedDepth = 0; if(directory.is_absolute() && path.is_absolute()){ filesystem::path compactPath; makePathCompact(path, compactPath); filesystem::path::const_iterator p = directory.begin(); filesystem::path::const_iterator q = compactPath.begin(); while(p != directory.end() && q != compactPath.end()){ if(!comparePathIterator(p, q)){ break; } ++numMatchedDepth; ++p; ++q; } if(p == directory.end()){ out_subdirectory.clear(); while(q != compactPath.end()){ out_subdirectory /= *q++; } return numMatchedDepth; } } return 0; }
static std::wstring s_abs_path(const filesystem::path& file) { if (!file.is_absolute()) return (s_path / file).wstring(); else return file.wstring(); }