Skip to content

Commit 560d26d

Browse files
Renaming duplicated asset filenames. (o3de#515)
Signed-off-by: Kacper Lewandowski <[email protected]>
1 parent 01455c6 commit 560d26d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Gems/ROS2/Code/Source/RobotImporter/Utils/SourceAssetsStorage.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ namespace ROS2::Utils
319319
return urdfAssetMap;
320320
}
321321
auto amentPrefixPath = Utils::GetAmentPrefixPath();
322-
AZStd::set<AZStd::string> files;
322+
AZStd::unordered_map<AZStd::string, unsigned int> countFilenames;
323323

324324
for (const auto& unresolvedUrfFileName : meshesFilenames)
325325
{
@@ -335,8 +335,17 @@ namespace ROS2::Utils
335335
const bool needsVisual = visuals.contains(unresolvedUrfFileName);
336336
const bool needsCollider = colliders.contains(unresolvedUrfFileName);
337337

338-
AZ::IO::Path targetPathAssetDst(importDirectoryDst / resolvedPath.Filename());
339-
AZ::IO::Path targetPathAssetTmp(importDirectoryTmp / resolvedPath.Filename());
338+
AZStd::string filename = resolvedPath.Filename().String();
339+
auto count = countFilenames[filename]++;
340+
if (count > 0)
341+
{
342+
AZStd::string stem = resolvedPath.Stem().String();
343+
AZStd::string extension = resolvedPath.Extension().String();
344+
filename = AZStd::string::format("%s_dup_%u%s", stem.c_str(), count, extension.c_str());
345+
}
346+
347+
AZ::IO::Path targetPathAssetDst(importDirectoryDst / filename);
348+
AZ::IO::Path targetPathAssetTmp(importDirectoryTmp / filename);
340349

341350
AZ::IO::Path targetPathAssetInfo(targetPathAssetDst.Native() + ".assetinfo");
342351

0 commit comments

Comments
 (0)