fixes behaviour of folder and file detections in java 16, fixes #869
This commit is contained in:
1 parent
f21897fab1
commit
c6db496a1f
1 file changed
+5
-1
@@ -222,7 +222,10 @@ public class FileArgument
|
|||||||
String ext = type.extension;
|
String ext = type.extension;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Files.list(dir).filter(path -> (type==Type.FOLDER)?path.toString().endsWith("/"):path.toString().endsWith(ext));
|
return Files.list(dir).filter(path -> (type==Type.FOLDER)
|
||||||
|
?Files.isDirectory(path)
|
||||||
|
:(Files.isRegularFile(path) && path.toString().endsWith(ext))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (IOException ignored)
|
catch (IOException ignored)
|
||||||
{
|
{
|
||||||
@@ -252,6 +255,7 @@ public class FileArgument
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
if (type == Type.FOLDER)
|
if (type == Type.FOLDER)
|
||||||
|
// java 8 paths are inconsistent. in java 16 they all should not have trailing slashes
|
||||||
return strings.map(s -> s.endsWith("/")?s.substring(0, s.length()-1):s);
|
return strings.map(s -> s.endsWith("/")?s.substring(0, s.length()-1):s);
|
||||||
return strings.map(FilenameUtils::removeExtension);
|
return strings.map(FilenameUtils::removeExtension);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user