some refactor

This commit is contained in:
Radek Davidek 2026-04-29 20:19:17 +02:00
parent aaf5ea7ce9
commit 0a3f3e75e0
3 changed files with 11 additions and 25 deletions

View File

@ -887,27 +887,7 @@ public class FileOperations {
}
boolean contentMatched = true;
if (nameMatched && contentPattern != null) {
final SevenZFile szfFinal = sevenZFile;
InputStream is = new InputStream() {
@Override
public int read() throws IOException {
try {
return szfFinal.read();
} catch (PasswordRequiredException e) {
throw new IOException("Password required", e);
}
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
try {
return szfFinal.read(b, off, len);
} catch (PasswordRequiredException e) {
throw new IOException("Password required", e);
}
}
};
contentMatched = searchInStream(is, contentPattern);
contentMatched = searchInSevenZEntry(sevenZFile, contentPattern);
}
if (nameMatched && contentMatched) {
callback.onFileFound(archive, archive.getAbsolutePath() + File.separator + entry.getName());
@ -968,6 +948,16 @@ public class FileOperations {
return false;
}
private static boolean searchInSevenZEntry(SevenZFile sevenZFile, Pattern contentPattern) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[65536];
int len;
while ((len = sevenZFile.read(buffer)) > 0) {
baos.write(buffer, 0, len);
}
return contentPattern.matcher(new String(baos.toByteArray())).find();
}
/**
* Zip files/directories into a target zip file
*/

View File

@ -10,7 +10,6 @@ import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
/**

View File

@ -729,9 +729,6 @@ public class FilePanel extends JPanel {
*/
public void setActive(boolean active, Color activeColor) {
this.active = active;
// Inactive indicator is subtle dark gray
Color inactiveColor = new Color(60, 60, 60);
Color targetColor = active ? activeColor : inactiveColor;
// Remove the horizontal line above tabs.
tabbedPane.setBorder(null);