Checking if path or extension is not empty

This commit is contained in:
JoseM98 2024-05-08 15:34:49 +02:00 committed by Blyron
parent 1ea2827c62
commit 4aa2e3c934
2 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@ namespace carla {
void FileSystem::ValidateFilePath(std::string &filepath, const std::string &ext) {
fs::path path(filepath);
if (path.extension() != ext)
if (!ext.empty() && path.extension() != ext)
path.replace_extension(ext);
auto parent = path.parent_path();
if (!fs::exists(parent))

View File

@ -538,7 +538,7 @@ void FCarlaServer::FPimpl::BindActions()
REQUIRE_CARLA_EPISODE();
// Check that the path ends in a slash, add it otherwise
if (folder[folder.size() - 1] != '/' && folder[folder.size() - 1] != '\\') {
if (!folder.empty() && folder[folder.size() - 1] != '/' && folder[folder.size() - 1] != '\\') {
folder += "/";
}