Skip to content

Commit

Permalink
fix(gui): trim trailing spaces in input files (#2244)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Aug 9, 2024
1 parent 280f387 commit 015876b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,18 @@ public static List<Path> toPaths(File[] files) {
return Stream.of(files).map(File::toPath).collect(Collectors.toList());
}

public static List<Path> toPathsWithTrim(File[] files) {
return Stream.of(files).map(FileUtils::toPathWithTrim).collect(Collectors.toList());
}

public static Path toPathWithTrim(File file) {
return Path.of(file.getPath().stripTrailing());
}

public static Path toPathWithTrim(String file) {
return Path.of(file.stripTrailing());
}

public static List<Path> fileNamesToPaths(List<String> fileNames) {
return fileNames.stream().map(Paths::get).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public List<Path> showDialog() {
data.setCurrentDir(getCurrentDirectory().toPath());
File[] selectedFiles = getSelectedFiles();
if (selectedFiles.length != 0) {
return FileUtils.toPaths(selectedFiles);
return FileUtils.toPathsWithTrim(selectedFiles);
}
File chosenFile = getSelectedFile();
if (chosenFile != null) {
return Collections.singletonList(chosenFile.toPath());
return Collections.singletonList(FileUtils.toPathWithTrim(chosenFile));
}
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public List<Path> showDialog() {
File[] selectedFiles = fileDialog.getFiles();
if (!Utils.isEmpty(selectedFiles)) {
data.setCurrentDir(Paths.get(fileDialog.getDirectory()));
return FileUtils.toPaths(selectedFiles);
return FileUtils.toPathsWithTrim(selectedFiles);
}
if (fileDialog.getFile() != null) {
return Collections.singletonList(Paths.get(fileDialog.getFile()));
return Collections.singletonList(FileUtils.toPathWithTrim(fileDialog.getFile()));
}
return Collections.emptyList();
}
Expand Down

0 comments on commit 015876b

Please sign in to comment.