Reading files in .rar archive without unzipping

I am trying to get a listing of the files contained in a .rar (unencrypted) archive without unzipping the archive each time I want to run the script. There is a method to get the files listed in a zip archive, but since I'm using this for storage purposes, I am saving as a .rar for better compression.
This post describes a procedure by which one can obtain a list of the files inside a zip archive, but I can't get it to work with a rar archive. Any help would be great. Thanks.

Risposte (1)

For the task of getting the list of files in a rar, without extracting them, https://stackoverflow.com/questions/561107/rar-archives-with-java
(RAR license is restrictive about doing extraction.)

8 Commenti

This looks interesting, but I'm not familiar with what I'm looking at here, and I'm not sure how MATLAB would interface with Java (the code provided in the other post was quite foreign to me, as I have never used MATLAB to call/manipulate other programs before).
java_filename = java.lang.String('PathToRarFileGoesHere.rar');
rar_file = RARFile(java_filename);
entries = rar_file.entries();
count = 0;
while (entries.hasMoreElements())
entry = entries.nextElement();
entry_name = entry.getName().toCharArray';
count = count + 1;
fprintf('#%d: %s\n', count, entry_name);
end
This is great.
If I'm understanding correctly, I download the zip file from that GitHub project, extract that, and then add
javaaddpath('FileDirectoryWhereIExtractedZIP\RARFile.java')
which gives me access to calling
RARFile('...')
as in your example?
I think you just add the directory in javaaddpath, not the .java file itself.
Great, I'll give this a try when I get back to the office. It looked like the documentation example used a .jar file, which is why I was thinking the .java would be closest. Thanks for the help.
Publius
Publius il 2 Ago 2022
Modificato: Publius il 2 Ago 2022
@Walter Roberson So I've tried this in my code, but I'm getting an "Undefined function 'RARFile' for input arguments of type 'java.lang.String'." error. I tried redirecting the javaaddpath command to the main directory where I unzipped the ZIP file from the GitHub, and I tried directing the javaaddpath to the gradle-wrapper.jar file (which appears to be the only .jar file in the download). I also tried directing it to the RARFile.java file contained in the file structure. All produced the same error. Any ideas?
Hmmm, the documentation at https://github.com/radarsh/raroscope hints that it needs to be compiled into a .jar -- see the "Gradle" part
I found some sources online that said you could just change a .zip extension into a .jar, and Windows seemed okay with that. No joy referencing that jar though. Same error. I am trying to install Gradle, but it is really complicated (wish they just provided an exe!). Do you have any recommendations on making the .jar file?

Accedi per commentare.

Prodotti

Release

R2020b

Richiesto:

il 28 Lug 2022

Commentato:

il 3 Ago 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by