Unrar with a command line

Discussion in 'Mac Programming' started by moivhod, Apr 8, 2017.

  1. moivhod macrumors newbie

    Joined:
    Apr 8, 2017
    #1
    I’m creating an app and one of its functions must be unpacking of a rar archive. I found couple of command line tools like here: http://www.rarlab.com/download.htm and here: http://unarchiver.c3.cx/commandline, but they require preliminary installation to be launched with a command line.


    So how can my app launch any other app (child process) to unpack a rar file? I code using FireMoneky with C++ Builder (under Windows) and so far I can’t find there any cross-platform function to extract rar, that’s why I came up with an idea of extracting for Mac through a command line. Maybe my whole idea is wrong and not doable because of Mac security reasons. Would appreciate any input here. Thanks!
     
  2. Toutou macrumors 6502a

    Toutou

    Joined:
    Jan 6, 2015
    Location:
    Prague, Czech Republic
    #2
    RAR is a proprietary format, so unless the extraction algorithm is baked right into your app (and you have the licensing stuff sorted out) you can't count on any support. Is this feature really necessary? There are alternatives.
     
  3. moivhod, Apr 8, 2017
    Last edited: Apr 8, 2017

    moivhod thread starter macrumors newbie

    Joined:
    Apr 8, 2017
    #3
    Yep) The app I'm coding is sort of downloader and extractor the same time. It must help clients who purchased some digital products to download and unpack them correctly. Because many people, believe me, do have problem to do it manually by themselves)

    So far I succeeded with this free command line extractor http://unarchiver.c3.cx/commandline by just typing in the Terminal
    Code:
    ./unar x archive.rar
    Hopefully, I'll be able to incorporate it in my app
     
  4. Toutou macrumors 6502a

    Toutou

    Joined:
    Jan 6, 2015
    Location:
    Prague, Czech Republic
    #4
    Yeah, if you manage to bundle the unar binary with your app, it should be easy to launch it from your C++ code (if you've never done this: the system() function is your friend).

    You could even take the source and use your desired functionality — with a bit of hacking around — directly in your own code, it says in License.txt that it's okay if you ask the author.
     

Share This Page