Display path string and path bytes when an error occurs

This commit is contained in:
apriestman 2021-05-27 10:58:31 -04:00
parent faf4e9a70a
commit f4d521cb7c

View File

@ -1309,13 +1309,29 @@ class SevenZipExtractor {
} }
if (tokens.size() != byteTokens.size()) { if (tokens.size() != byteTokens.size()) {
logger.log(Level.WARNING, "Could not map path bytes to path string"); logger.log(Level.WARNING, "Could not map path bytes to path string (path string: \"{0}\", bytes: {1})",
new Object[]{filePath, bytesToString(filePathBytes)});
return addNode(rootNode, tokens, null); return addNode(rootNode, tokens, null);
} }
} }
return addNode(rootNode, tokens, byteTokens); return addNode(rootNode, tokens, byteTokens);
} }
/**
* Convert byte array to string representation.
*
* @param bytes Byte array
*
* @return Byte array as lower case hex string.
*/
private String bytesToString(byte[] bytes) {
StringBuilder result = new StringBuilder();
for (byte b : bytes) {
result.append(String.format("%02x", b));
}
return result.toString();
}
/** /**
* recursive method that traverses the path * recursive method that traverses the path