There was an error while loading. Please reload this page.
1 parent 44d6cda commit d1075ffCopy full SHA for d1075ff
1 file changed
util/src/main/java/nl/inl/util/FileUtil.java
@@ -170,16 +170,7 @@ public void process(File f) {
170
* @return true if the file is in the directory or one of its subdirectories, false otherwise
171
*/
172
public static boolean isFileInDirectory(File file, File directory) {
173
- File parent = file.getParentFile();
174
- boolean ok = false;
175
- while (parent != null) {
176
- if (parent.equals(directory)) {
177
- ok = true;
178
- break;
179
- }
180
- parent = parent.getParentFile();
181
182
- return ok;
+ return file.toPath().normalize().startsWith(directory.toPath().normalize());
183
}
184
185
/**
0 commit comments