Skip to content

Commit

Permalink
isSameFile
Browse files Browse the repository at this point in the history
  • Loading branch information
guwirth committed Aug 23, 2024
1 parent c86b695 commit 8557fdf
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -400,6 +401,16 @@ private Iterable<InputFile> getInputFiles(SensorContext context, CxxSquidConfigu
&& context.config().getBoolean(JSON_COMPILATION_DATABASE_ONLY_CONTAINED_FILES_KEY).orElse(Boolean.FALSE)) {
// if the source of the configuration is JSON Compilation Database and analyzeOnlyContainedFiles=True,
// then analyze only the files contained in the db.

for (var squidFilePath : squidConfig.getFiles()) {
for (var inputFile : inputFiles) {
var inputFilePath = Path.of(inputFile.uri());
if (Files.isSameFile(squidFilePath, inputFilePath)) {
LOG.info("match '{}'='{}'", squidFilePath, inputFilePath);
}
}
}

var inputFilesInConfig = new ArrayList<Path>();
// resolution of symbolic links and case-sensitive paths: In Json DB the path/filenames are often lowercase
for (var inputfile : squidConfig.getFiles()) {
Expand All @@ -409,6 +420,7 @@ private Iterable<InputFile> getInputFiles(SensorContext context, CxxSquidConfigu
// ...
}
}

LOG.info("Paths in Config': {} files", inputFilesInConfig.toString());
var result = StreamSupport.stream(inputFiles.spliterator(), false)
.filter(f -> inputFilesInConfig.contains(Path.of(f.uri())))
Expand Down

0 comments on commit 8557fdf

Please sign in to comment.