fix: translate given dir paths to real paths
*/
package com.synopsys.integration.detect.workflow.file;
+import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;
+import org.jetbrains.annotations.Nullable;
+
public class DirectoryOptions {
private final Path sourcePath;
private final Path outputPath;
@@ -32,12 +35,12 @@ public class DirectoryOptions {
private final Path scanOutputPath;
private final Path toolsOutputPath;
- public DirectoryOptions(final Path sourcePath, final Path outputPath, final Path bdioOutputPath, final Path scanOutputPath, final Path toolsOutputPath) {
- this.sourcePath = sourcePath;
- this.outputPath = outputPath;
- this.bdioOutputPath = bdioOutputPath;
- this.scanOutputPath = scanOutputPath;
- this.toolsOutputPath = toolsOutputPath;
+ public DirectoryOptions(Path sourcePath, Path outputPath, Path bdioOutputPath, Path scanOutputPath, Path toolsOutputPath) throws IOException {
+ this.sourcePath = toRealPath(sourcePath);
+ this.outputPath = toRealPath(outputPath);
+ this.bdioOutputPath = toRealPath(bdioOutputPath);
+ this.scanOutputPath = toRealPath(scanOutputPath);
+ this.toolsOutputPath = toRealPath(toolsOutputPath);
}
public Optional<Path> getSourcePathOverride() {
@@ -59,4 +62,12 @@ public class DirectoryOptions {
public Optional<Path> getToolsOutputPath() {
return Optional.ofNullable(toolsOutputPath);
}
+
+ @Nullable
+ private Path toRealPath(@Nullable Path rawPath) throws IOException {
+ if (rawPath == null) {
+ return null;
+ }
+ return rawPath.toRealPath();
+ }
}
