Skip to content

Commit

Permalink
'#1861 Opens directory stream to check if path is directory only if path
Browse files Browse the repository at this point in the history
has trailing space.
  • Loading branch information
patrickdalla committed Oct 25, 2023
1 parent d0b1a01 commit 6a21769
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions iped-utils/src/main/java/iped/utils/FileInputStreamFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ public Path getPath(String subPath) {
}

boolean isDirectory(String path) {
try (DirectoryStream ds = Files.newDirectoryStream(Path.of(path))) {
} catch (NotDirectoryException ioe) {
return false;
} catch (IOException e) {
if (path.endsWith(" ")) {
try (DirectoryStream ds = Files.newDirectoryStream(Path.of(path))) {
} catch (NotDirectoryException ioe) {
return false;
} catch (IOException e) {
return new File(path).isDirectory();
}
return true;
} else {
return new File(path).isDirectory();
}
return true;
}

@Override
Expand Down

0 comments on commit 6a21769

Please sign in to comment.