Add the error output for syncqt normilizedPath function

Task-number: QTBUG-123438
Pick-to: 6.5 6.6 6.7
Change-Id: If718d774daac2fd4a9e27ad4725a74362d1c78f3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
bb10
Alexey Edelev 2024-03-18 16:58:55 +01:00
parent df8c3d40c8
commit 7aecb189d5
1 changed files with 12 additions and 5 deletions

View File

@ -136,17 +136,24 @@ void printInternalError()
<< std::endl;
}
std::filesystem::path normilizedPath(const std::string &path)
{
return std::filesystem::path(std::filesystem::weakly_canonical(path).generic_string());
}
void printFilesystemError(const std::filesystem::filesystem_error &fserr, std::string_view errorMsg)
{
std::cerr << errorMsg << ": " << fserr.path1() << ".\n"
<< fserr.what() << "(" << fserr.code().value() << ")" << std::endl;
}
std::filesystem::path normilizedPath(const std::string &path)
{
try {
auto result = std::filesystem::path(std::filesystem::weakly_canonical(path).generic_string());
return result;
} catch (const std::filesystem::filesystem_error &fserr) {
printFilesystemError(fserr, "Unable to normalize path");
throw;
}
return {};
}
bool createDirectories(const std::string &path, std::string_view errorMsg, bool *exists = nullptr)
{
bool result = true;