Make sure we reject files that are not children of a sync-path
This commit is contained in:
parent
0b9d6093a0
commit
fdbde2e0a6
6 changed files with 99 additions and 19 deletions
17
src/main/java/ru/bclib/util/PathUtil.java
Normal file
17
src/main/java/ru/bclib/util/PathUtil.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package ru.bclib.util;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class PathUtil {
|
||||
public static boolean isChildOf(Path parent, Path child){
|
||||
if (child==null || parent==null) return false;
|
||||
|
||||
final int pCount = parent.getNameCount();
|
||||
final int cCount = child.getNameCount();
|
||||
|
||||
if (cCount > pCount) return isChildOf(parent, child.getParent());
|
||||
if (cCount < pCount) return false;
|
||||
|
||||
return child.equals(parent);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue