MCPcopy Create free account
hub / github.com/FabricMC/Matcher / resolvePaths

Method resolvePaths

src/main/java/matcher/Matcher.java:132–171  ·  view source on GitHub ↗
(Collection<Path> inputDirs, Collection<InputFile> inputFiles)

Source from the content-addressed store, hash-verified

130 }
131
132 public static List<Path> resolvePaths(Collection<Path> inputDirs, Collection<InputFile> inputFiles) throws IOException {
133 List<Path> ret = new ArrayList<>(inputFiles.size());
134
135 inputFileLoop: for (InputFile inputFile : inputFiles) {
136 if (inputFile.pathHint != null) {
137 if (inputFile.pathHint.isAbsolute()) {
138 if (Files.isRegularFile(inputFile.pathHint) && inputFile.equals(inputFile.pathHint)) {
139 ret.add(inputFile.pathHint);
140 continue inputFileLoop;
141 }
142 } else {
143 for (Path inputDir : inputDirs) {
144 Path file = inputDir.resolve(inputFile.pathHint);
145
146 if (Files.isRegularFile(file) && inputFile.equals(file)) {
147 ret.add(file);
148 continue inputFileLoop;
149 }
150 }
151 }
152 }
153
154 for (Path inputDir : inputDirs) {
155 try (Stream<Path> matches = Files.find(inputDir, Integer.MAX_VALUE, (path, attr) -> inputFile.equals(path), FileVisitOption.FOLLOW_LINKS)) {
156 Path file = matches.findFirst().orElse(null);
157
158 if (file != null) {
159 ret.add(file);
160 continue inputFileLoop;
161 }
162 } catch (UncheckedIOException e) {
163 throw e.getCause();
164 }
165 }
166
167 throw new IOException("can't find input "+inputFile);
168 }
169
170 return ret;
171 }
172
173 public void match(ClassInstance a, ClassInstance b) {
174 if (a == null) throw new NullPointerException("null class A");

Callers 2

initFromMatchesMethod · 0.95
resolvePathMethod · 0.95

Calls 2

sizeMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected