Skip to content

Commit

Permalink
Refs #13740: Solved backport conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Juanjo Garcia <[email protected]>
  • Loading branch information
juanjo4936 committed Jan 13, 2025
1 parent 1ad57cf commit 454a49c
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.IOError;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -282,7 +285,11 @@ else if (arg.equals("-I"))
{
if (count < args.length)
{
m_includePaths.add("-I".concat(args[count++]));
String pathStr = args[count++];
if (!isIncludePathDuplicated(pathStr))
{
m_includePaths.add("-I".concat(pathStr));
}
}
else
{
Expand Down Expand Up @@ -510,6 +517,42 @@ private void showVersion()
System.out.println(m_appName + " version " + version);
}

private boolean isIncludePathDuplicated(String pathToCheck)
{
try
{
Path path = Paths.get(pathToCheck);
String absPath = path.toAbsolutePath().toString();
boolean isDuplicateFound = false;
for (String includePath : m_includePaths)
{
// include paths are prefixed with "-I"
if (includePath.length() <= 2)
{
continue;
}
String absIncludePath = Paths.get(includePath.substring(2)).toAbsolutePath().toString();
if (absPath.toLowerCase().equals(absIncludePath.toLowerCase()))
{
isDuplicateFound = true;
break;
}
}

if (isDuplicateFound)
{
return true;
}

}
catch (InvalidPathException | IOError | SecurityException ex)
{
// path operations failed, just returning false
}

return false;
}

public static void printHelp()
{
System.out.println(m_appName + " usage:");
Expand Down

0 comments on commit 454a49c

Please sign in to comment.