-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS agnostic path separator #3064
Conversation
this->setBasePath(this->getGraphName() + "/"); | ||
else if (providedBasePath.back() == '/') | ||
this->setBasePath(this->getGraphName() + std::string(1, std::filesystem::path::preferred_separator)); | ||
else if (providedBasePath.back() == std::string(1, std::filesystem::path::preferred_separator).back()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this back() needed?
else if (providedBasePath.back() == std::string(1, std::filesystem::path::preferred_separator).back()) | |
else if (providedBasePath.back() == std::string(1, std::filesystem::path::preferred_separator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need char to compare.
@@ -563,7 +563,7 @@ TEST_F(TestLoadModel, CheckSavedModelHandling) { | |||
auto model_files = modelInstance.getModelFiles(); | |||
ASSERT_FALSE(model_files.empty()); | |||
#ifdef _WIN32 | |||
EXPECT_EQ(model_files.front(), directoryPath + "/test_saved_model/1\\"); | |||
EXPECT_EQ(model_files.front(), directoryPath + "/test_saved_model\\1\\"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add function so we could use sth like this without macro's?
EXPECT_EQ(model_files.front(), directoryPath + "/test_saved_model\\1\\"); | |
EXPECT_EQ(model_files.front(), os_agnostic_path(directoryPath + "/test_saved_model/1/")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those the only places where we encounter with the different separator handling of Win/Lin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a case by case result for different tests. Part of path is from config or hardcoded and the rest is generated by ovms. So the number of ifdef would be the same.
src/filesystem.hpp
Outdated
} else { | ||
rootDirectoryPath = currentWorkingDir + "/"; | ||
rootDirectoryPath = currentWorkingDir + std::string(1, std::filesystem::path::preferred_separator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make macro out of std::string(1, std::filesystem::path::preferred_separator)
? or even declare it as constexpr so it is created only once
src/filesystem.cpp
Outdated
@@ -116,4 +116,9 @@ std::string FileSystem::findFilePathWithExtension(const std::string& path, const | |||
return std::string(); | |||
} | |||
|
|||
std::string& FileSystem::getOsSeparator() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return const reference
🛠 Summary
JIRA CVS-160424
Switch to os agnostic path separator.
🧪 Checklist
``