Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
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.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -273,7 +275,10 @@ else if (arg.equals(include_path_arg))
{
if (count < args.length)
{
m_includePaths.add(include_path_arg.concat(args[count++]));
String pathStr = args[count++];
if (!isIncludePathDuplicated(pathStr)) {
m_includePaths.add(include_path_arg.concat(pathStr));
}
}
else
{
Expand Down Expand Up @@ -560,8 +565,31 @@ 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;
}

/*
* ----------------------------------------------------------------------------------------
* Arguments
Expand Down