Skip to content

Commit

Permalink
'#1861: check if file is a folder and create a temp folder for it
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Sep 22, 2023
1 parent af654e3 commit 11123b3
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions iped-utils/src/main/java/iped/utils/FileInputStreamFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,22 @@ public Path getPath(String subPath) {
}
if (IS_WINDOWS) {
// workaround for https://github.com/sepinf-inc/IPED/issues/1861
File f = new File("\\\\?\\" + file.getAbsolutePath());
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f))) {
file = File.createTempFile("iped", ".tmp");
file.deleteOnExit();
Files.copy(bis, file.toPath(), StandardCopyOption.REPLACE_EXISTING);

} catch (IOException e1) {
throw new RuntimeException(e1);
if (file.isDirectory()) {
try {
file = Files.createTempDirectory("iped").toFile();
file.deleteOnExit();
} catch (IOException e1) {
throw new RuntimeException(e1);
}
} else {
File f = new File("\\\\?\\" + file.getAbsolutePath());
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f))) {
file = File.createTempFile("iped", ".tmp");
file.deleteOnExit();
Files.copy(bis, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e1) {
throw new RuntimeException(e1);
}
}
}
return file.toPath();
Expand Down

0 comments on commit 11123b3

Please sign in to comment.