Is there an unrar library out there for iOS?
Asked Answered
M

3

7

I want to include an unrar files option in my iphone app.

I have already tried https://github.com/ararog/Unrar4iOS but this library is not complete (some functions are not yet implemented like -(BOOL) unrarFileTo:(NSString*)path overWrite:(BOOL)overwrite)

Thanks.

Misadvise answered 16/10, 2011 at 16:28 Comment(4)
For future reference, you'll get better search results if you consider "language and API" versus "OS", otherwise you'll miss perfectly good libraries and sample code that works equally well on iOS or Mac OS X. Start with "unrar objective-c" for the broadest results.Macaw
Please search the site. This has been asked a good half-dozen times before.Giltzow
Obviously I searched extensively before asking this question.Misadvise
Alex: Obviously? Obvious to whom? None of us are privy to your browsing history and you did not say where you've looked and why the results that can be found don't work for you. In fact you apparently already tried something (your response to omz's response) that didn't work for you but you failed to mention it. Sorry, but there's nothing "obvious" about what you did or didn't do. It's better to take responsibility for the clarity of your own questions so you can make them better (and help us give you better answers).Macaw
M
5

I ended up using Unrar4ios but I needed to write myself the function that actually extracts the rar file:

-(BOOL) unrarFileTo:(NSString*)path overWrite:(BOOL)overwrite {

    int RHCode = 0, PFCode = 0;

    [self _unrarOpenFile:filename mode:RAR_OM_EXTRACT];

    while ((RHCode = RARReadHeaderEx(_rarFile, header)) == 0) {

        if ((PFCode = RARProcessFile(_rarFile, RAR_EXTRACT, (char *)[path UTF8String], NULL)) != 0) {
            [self _unrarCloseFile];
            return NO;
        }

    }

    [self _unrarCloseFile];


    return YES;
}
Misadvise answered 23/10, 2011 at 13:9 Comment(5)
Consider submitting a pull request on github, to help the original project.Caste
@Moshe: Gladly. The problem is that I'm not too familiar with github - Can you please give me a short explanation (or a link) on how to do that?Misadvise
I'm not a GitHub pro myself, but essentially, you need to fork the repo, make your changes, push a commit, and then request a pull. I'll grab a link if I find one.Caste
@pacoflaco It seems that the framework is not "global", in a way that it can work only for the simulator and not for the device... I didn't have time to dig into how to create a framework in xcode 4 so what I did was to create a static library (.a file) of Unrar4ios file and then added it to my main project (with the headers). Of course here I had to create a "universal" static library so I used a run script from here #3521477 (Adam's answer)...Misadvise
@Misadvise i tried but appear an error "use of undeclared identifier 'archive'", can you upload your static library?Martyry
J
4

This might help: https://github.com/ararog/Unrar4iOS

Jejunum answered 16/10, 2011 at 16:31 Comment(4)
I already tried this library - but it is somewhat incomplete. If you look at the source you will see that some functions are not implemented most importantly -(BOOL) unrarFileTo:(NSString*)path overWrite:(BOOL)overwrite.Misadvise
@Alex: Have you looked at the example project that comes with it? Particularly the -decompress: method of ./UnrarExample/Classes/UnrarExampleViewController.mm? Seems to work fine.Macaw
@JoshuaNozzi It works becuase he uses a different method called extractStream, which basically returns you an NSData object. It might work when we are talking about images (like in the project) - but not when it comes to bigger files.Misadvise
...that's exactly the kind of thing you should put in your original question so we don't do things like spend time searching the suggested library you already tried to find a method that doesn't work for a reason you already knew. ;-)Macaw
K
0

The unrarlib library should work for you, since Objective C is a superset of C.

Kabuki answered 21/10, 2011 at 0:29 Comment(1)
Have you actually tried it? It's a very old project (2002-2004) and doesn't support rar 3.x archivesMisadvise

© 2022 - 2024 — McMap. All rights reserved.